Channel Info
The channel detail panel that covers a channel on narrow screens.
The channel detail panel that covers a channel on narrow screens. Compose it from the exported registry parts so local content and behaviour stay in the application while the visual contract stays token-driven.
newt-channel-infoimport {
ChannelInfo,
ChannelInfoAction,
ChannelInfoActions,
ChannelInfoEmpty,
ChannelInfoEmptyBody,
ChannelInfoEmptyIcon,
ChannelInfoEmptyTitle,
ChannelInfoIcon,
ChannelInfoIdentity,
ChannelInfoName,
ChannelInfoPanel,
ChannelInfoToolbar,
ChannelInfoType,
} from "@/registry/bases/newt/ui/channel-info"
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@/registry/bases/newt/ui/tabs"
export default function ChannelInfoDemo() {
return (
<ChannelInfo
inline
label="Channel information for #general"
className="h-[420px] rounded-md"
>
<ChannelInfoToolbar>
<ChannelInfoAction aria-label="Back to channel">
<svg viewBox="0 0 20 20" className="h-5 w-5" fill="currentColor">
<path d="M8.7 3.3 2 10l6.7 6.7 1.4-1.4L5.8 11H18V9H5.8l4.3-4.3-1.4-1.4Z" />
</svg>
</ChannelInfoAction>
<ChannelInfoActions>
<ChannelInfoAction aria-label="Search">
<svg
viewBox="0 0 20 20"
className="h-5 w-5"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
>
<circle cx="9" cy="9" r="5.5" />
<path d="M13 13l4 4" />
</svg>
</ChannelInfoAction>
<ChannelInfoAction aria-label="Notification settings">
<svg viewBox="0 0 20 20" className="h-5 w-5" fill="currentColor">
<path d="M10 2a5 5 0 0 0-5 5v3.5L3.5 13v1h13v-1L15 10.5V7a5 5 0 0 0-5-5Zm0 16a2.5 2.5 0 0 0 2.45-2h-4.9A2.5 2.5 0 0 0 10 18Z" />
</svg>
</ChannelInfoAction>
</ChannelInfoActions>
</ChannelInfoToolbar>
<ChannelInfoIdentity>
<ChannelInfoIcon />
<div className="min-w-0">
<ChannelInfoName>general</ChannelInfoName>
<ChannelInfoType>Text Channel</ChannelInfoType>
</div>
</ChannelInfoIdentity>
{/* `contents` lets the tab strip and the panel sit directly in the
panel column; the panel is a sibling of the tab list, not inside it. */}
<Tabs defaultValue="threads" className="contents">
<TabsList
aria-label="Channel information sections"
className="mx-2 w-auto"
>
<TabsTrigger value="members">Members</TabsTrigger>
<TabsTrigger value="pins">Pins</TabsTrigger>
<TabsTrigger value="threads">Threads</TabsTrigger>
</TabsList>
<ChannelInfoPanel>
<TabsContent value="members">
<ChannelInfoEmpty>
<ChannelInfoEmptyTitle>No members to show.</ChannelInfoEmptyTitle>
</ChannelInfoEmpty>
</TabsContent>
<TabsContent value="pins">
<ChannelInfoEmpty>
<ChannelInfoEmptyTitle>
No pinned messages yet.
</ChannelInfoEmptyTitle>
</ChannelInfoEmpty>
</TabsContent>
<TabsContent value="threads">
<ChannelInfoEmpty>
<ChannelInfoEmptyIcon>
<svg
viewBox="0 0 24 24"
className="h-8 w-8"
fill="currentColor"
>
<path d="M4 4h16v10H8l-4 4V4Z" />
</svg>
</ChannelInfoEmptyIcon>
<ChannelInfoEmptyTitle>
There are no threads.
</ChannelInfoEmptyTitle>
<ChannelInfoEmptyBody>
Stay focused on a conversation with a thread — a temporary
text channel.
</ChannelInfoEmptyBody>
</ChannelInfoEmpty>
</TabsContent>
</ChannelInfoPanel>
</Tabs>
</ChannelInfo>
)
}<script setup lang="ts">
import {
ChannelInfo,
ChannelInfoAction,
ChannelInfoActions,
ChannelInfoEmpty,
ChannelInfoEmptyBody,
ChannelInfoEmptyIcon,
ChannelInfoEmptyTitle,
ChannelInfoIcon,
ChannelInfoIdentity,
ChannelInfoName,
ChannelInfoPanel,
ChannelInfoToolbar,
ChannelInfoType,
} from "~~/registry/bases/newt/ui/channel-info"
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "~~/registry/bases/newt/ui/tabs"
</script>
<template>
<ChannelInfo
inline
label="Channel information for #general"
class="h-[420px] rounded-md"
>
<ChannelInfoToolbar>
<ChannelInfoAction aria-label="Back to channel">
<svg viewBox="0 0 20 20" class="h-5 w-5" fill="currentColor">
<path
d="M8.7 3.3 2 10l6.7 6.7 1.4-1.4L5.8 11H18V9H5.8l4.3-4.3-1.4-1.4Z"
/>
</svg>
</ChannelInfoAction>
<ChannelInfoActions>
<ChannelInfoAction aria-label="Search">
<svg
viewBox="0 0 20 20"
class="h-5 w-5"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
>
<circle cx="9" cy="9" r="5.5" />
<path d="M13 13l4 4" />
</svg>
</ChannelInfoAction>
<ChannelInfoAction aria-label="Notification settings">
<svg viewBox="0 0 20 20" class="h-5 w-5" fill="currentColor">
<path
d="M10 2a5 5 0 0 0-5 5v3.5L3.5 13v1h13v-1L15 10.5V7a5 5 0 0 0-5-5Zm0 16a2.5 2.5 0 0 0 2.45-2h-4.9A2.5 2.5 0 0 0 10 18Z"
/>
</svg>
</ChannelInfoAction>
</ChannelInfoActions>
</ChannelInfoToolbar>
<ChannelInfoIdentity>
<ChannelInfoIcon />
<div class="min-w-0">
<ChannelInfoName>general</ChannelInfoName>
<ChannelInfoType>Text Channel</ChannelInfoType>
</div>
</ChannelInfoIdentity>
<!--
`contents` lets the tab strip and the panel sit directly in the panel
column; the panel is a sibling of the tab list, not inside it.
-->
<Tabs default-value="threads" class="contents">
<TabsList aria-label="Channel information sections" class="mx-2 w-auto">
<TabsTrigger value="members">Members</TabsTrigger>
<TabsTrigger value="pins">Pins</TabsTrigger>
<TabsTrigger value="threads">Threads</TabsTrigger>
</TabsList>
<ChannelInfoPanel>
<TabsContent value="members">
<ChannelInfoEmpty>
<ChannelInfoEmptyTitle>No members to show.</ChannelInfoEmptyTitle>
</ChannelInfoEmpty>
</TabsContent>
<TabsContent value="pins">
<ChannelInfoEmpty>
<ChannelInfoEmptyTitle>
No pinned messages yet.
</ChannelInfoEmptyTitle>
</ChannelInfoEmpty>
</TabsContent>
<TabsContent value="threads">
<ChannelInfoEmpty>
<ChannelInfoEmptyIcon>
<svg viewBox="0 0 24 24" class="h-8 w-8" fill="currentColor">
<path d="M4 4h16v10H8l-4 4V4Z" />
</svg>
</ChannelInfoEmptyIcon>
<ChannelInfoEmptyTitle>
There are no threads.
</ChannelInfoEmptyTitle>
<ChannelInfoEmptyBody>
Stay focused on a conversation with a thread — a temporary
text channel.
</ChannelInfoEmptyBody>
</ChannelInfoEmpty>
</TabsContent>
</ChannelInfoPanel>
</Tabs>
</ChannelInfo>
</template>Installation
npx newtui@latest add channel-infonpx shadcn@latest add @newtui/channel-infonpx shadcn-vue@latest add @newtui/channel-infopnpm dlx newtui@latest add channel-infopnpm dlx shadcn@latest add @newtui/channel-infopnpm dlx shadcn-vue@latest add @newtui/channel-infoyarn dlx newtui@latest add channel-infoyarn dlx shadcn@latest add @newtui/channel-infoyarn dlx shadcn-vue@latest add @newtui/channel-infobunx newtui@latest add channel-infobunx shadcn@latest add @newtui/channel-infobunx shadcn-vue@latest add @newtui/channel-infodeno run -A npm:newtui@latest add channel-infodeno run -A npm:shadcn@latest add @newtui/channel-infodeno run -A npm:shadcn-vue@latest add @newtui/channel-infovlx newtui@latest add channel-infovlx shadcn@latest add @newtui/channel-infovlx shadcn-vue@latest add @newtui/channel-infovp dlx newtui@latest add channel-infovp dlx shadcn@latest add @newtui/channel-infovp dlx shadcn-vue@latest add @newtui/channel-infonubx newtui@latest add channel-infonubx shadcn@latest add @newtui/channel-infonubx shadcn-vue@latest add @newtui/channel-infonlx newtui@latest add channel-infonlx shadcn@latest add @newtui/channel-infonlx shadcn-vue@latest add @newtui/channel-infoupx newtui@latest add channel-infoupx shadcn@latest add @newtui/channel-infoupx shadcn-vue@latest add @newtui/channel-info- newtui
- shadcn
- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
The shadcn CLI needs the @newtui registry in your components.json. Set it up.
Install the dependencies
npm install radix-uipnpm add radix-uiyarn add radix-uibun add radix-uideno add npm:radix-uivlt install radix-uivp add radix-uinub add radix-uini radix-uiupm add radix-ui- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
npm install reka-uipnpm add reka-uiyarn add reka-uibun add reka-uideno add npm:reka-uivlt install reka-uivp add reka-uinub add reka-uini reka-uiupm add reka-ui- npm
- pnpm
- yarn
- bun
- deno
- vlt
- vp
- nub
- ni
- upm
Add the components it builds on
Copy the source into your project
"use client"
import { Dialog as DialogPrimitive } from "radix-ui"
import * as React from "react"
import { cn } from "@/lib/utils"
const channelInfoClassName =
"flex h-full w-full max-w-sm flex-col overflow-hidden bg-newt-bg-surface text-newt-text-primary"
export interface ChannelInfoProps extends React.ComponentProps<"div"> {
/**
* Render a plain panel: no dialog role, and focus stays where it is. Use it
* for a side panel that is always on screen.
*/
inline?: boolean
/**
* Take the page beside the panel out of use: it is hidden from assistive
* technology, focus cannot move to it, and a press on it closes the panel.
* Use it when the panel covers the channel. Has no effect on an `inline`
* panel.
*/
modal?: boolean
/**
* The accessible name of the panel. Without it, name the panel with
* `aria-label` or `aria-labelledby`.
*/
label?: string
/**
* Called when the user asks to close the dialog: Escape, or a press outside
* a `modal` one. Unmount the panel in answer; focus then returns to the
* element that held it before the panel opened.
*/
onClose?: () => void
}
/*
* Radix owns the behaviour: focus moves into the panel, Tab cycles through
* its controls, Escape asks to close it, and a `modal` one takes the page
* behind it out of use. The panel renders in place, with no portal and no
* overlay, so the application decides where it sits. It is open for as long
* as it is mounted.
*/
const ChannelInfoDialog = React.forwardRef<
HTMLDivElement,
Omit<ChannelInfoProps, "inline">
>(({ modal = false, label, onClose, className, children, ...props }, ref) => {
const opener = React.useRef<Element | null>(null)
return (
<DialogPrimitive.Root
open
modal={modal}
onOpenChange={(open) => {
if (!open) onClose?.()
}}
>
<DialogPrimitive.Content
ref={ref}
aria-modal={modal ? true : undefined}
aria-describedby={undefined}
/*
* Radix returns focus to a `Dialog.Trigger`, and this dialog has
* none: the application opens it by mounting it. So the panel notes
* which element holds focus just before it takes it.
*/
onOpenAutoFocus={() => {
opener.current = document.activeElement
}}
onCloseAutoFocus={(event) => {
event.preventDefault()
const element = opener.current
if (element instanceof HTMLElement && element.isConnected)
element.focus()
}}
/*
* The page beside a dialog that is not modal stays in use, so a press
* or a focus move outside must not close the panel.
*/
onInteractOutside={(event) => {
if (!modal) event.preventDefault()
}}
className={cn(channelInfoClassName, "outline-none", className)}
{...props}
>
{/* The name, as a heading no one sees: Radix points the dialog at it. */}
{label === undefined ? null : (
<DialogPrimitive.Title className="sr-only">
{label}
</DialogPrimitive.Title>
)}
{children}
</DialogPrimitive.Content>
</DialogPrimitive.Root>
)
})
ChannelInfoDialog.displayName = "ChannelInfoDialog"
/*
* The panel that slides in over a channel on narrow screens, holding the
* member list, pins, threads and the rest of the channel detail tabs. It is a
* dialog unless it is `inline`.
*/
const ChannelInfo = React.forwardRef<HTMLDivElement, ChannelInfoProps>(
({ inline = false, ...props }, ref) => {
if (!inline) return <ChannelInfoDialog ref={ref} {...props} />
const { modal: _modal, onClose: _onClose, label, role, ...rest } = props
return (
<div
ref={ref}
/* A name needs a role to hang on: a `div` alone may not carry one. */
role={role ?? (label === undefined ? undefined : "region")}
aria-label={label}
{...rest}
className={cn(channelInfoClassName, rest.className)}
/>
)
}
)
ChannelInfo.displayName = "ChannelInfo"
const ChannelInfoToolbar = React.forwardRef<
HTMLDivElement,
React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"flex h-14 shrink-0 items-center justify-between gap-2 px-2",
className
)}
{...props}
/>
))
ChannelInfoToolbar.displayName = "ChannelInfoToolbar"
const ChannelInfoActions = React.forwardRef<
HTMLDivElement,
React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex items-center gap-1", className)}
{...props}
/>
))
ChannelInfoActions.displayName = "ChannelInfoActions"
export interface ChannelInfoActionProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
/**
* The element or component to render. Defaults to `button`, or to `a` when
* `href` is set; pass a router link component to keep client navigation.
* `span` renders the decorative form: hidden from assistive technology, out
* of the tab order, with no pointer and no hover.
* Its event handlers do not run.
*/
as?: React.ElementType
/** Render a link to this URL. */
href?: string
/**
* Turns the control off. A link loses its URL, which takes it out of the
* tab order, and says so with `aria-disabled`.
*/
disabled?: boolean
/** Link target, with `href`. */
target?: React.AnchorHTMLAttributes<HTMLAnchorElement>["target"]
/** Link relationship, with `href`. */
rel?: string
}
/*
* The `span` form runs nothing: it drops every event handler, so a click
* cannot start an action that the keyboard and assistive technology miss.
*/
function withoutHandlers(
props: React.HTMLAttributes<HTMLElement>
): React.HTMLAttributes<HTMLElement> {
return Object.fromEntries(
Object.entries(props).filter(([name]) => !/^on[A-Z]/.test(name))
)
}
const ChannelInfoAction = React.forwardRef<HTMLElement, ChannelInfoActionProps>(
({ as, href, disabled, className, type = "button", ...props }, ref) => {
const Tag: React.ElementType = as ?? (href === undefined ? "button" : "a")
const isButton = Tag === "button"
const decorative = Tag === "span"
return (
<Tag
ref={ref}
type={isButton ? type : undefined}
href={decorative || disabled ? undefined : href}
disabled={isButton ? disabled : undefined}
aria-disabled={!isButton && !decorative && disabled ? true : undefined}
aria-hidden={decorative ? true : undefined}
className={cn(
"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-newt-text-secondary no-underline",
!decorative &&
"cursor-pointer transition-colors duration-fast ease-newt hover:bg-newt-bg-hover hover:text-newt-text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
className
)}
{...(decorative ? withoutHandlers(props) : props)}
/>
)
}
)
ChannelInfoAction.displayName = "ChannelInfoAction"
const ChannelInfoIdentity = React.forwardRef<
HTMLDivElement,
React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex min-w-0 items-center gap-3 px-4 pb-3", className)}
{...props}
/>
))
ChannelInfoIdentity.displayName = "ChannelInfoIdentity"
const ChannelInfoIcon = React.forwardRef<
HTMLDivElement,
React.ComponentProps<"div">
>(({ className, children = "#", ...props }, ref) => (
<div
ref={ref}
aria-hidden="true"
className={cn(
"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-newt-bg-elevated text-lg font-bold leading-none text-newt-text-muted",
className
)}
{...props}
>
{children}
</div>
))
ChannelInfoIcon.displayName = "ChannelInfoIcon"
const ChannelInfoName = React.forwardRef<
HTMLDivElement,
React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("truncate font-bold text-newt-text-primary", className)}
{...props}
/>
))
ChannelInfoName.displayName = "ChannelInfoName"
const ChannelInfoType = React.forwardRef<
HTMLDivElement,
React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("text-[13px] text-newt-text-muted", className)}
{...props}
/>
))
ChannelInfoType.displayName = "ChannelInfoType"
/* Scrolling area under the tab strip. */
const ChannelInfoPanel = React.forwardRef<
HTMLDivElement,
React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("min-h-0 flex-1 overflow-y-auto px-2 pb-4", className)}
{...props}
/>
))
ChannelInfoPanel.displayName = "ChannelInfoPanel"
const ChannelInfoEmpty = React.forwardRef<
HTMLDivElement,
React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"flex flex-col items-center gap-2 px-6 py-10 text-center",
className
)}
{...props}
/>
))
ChannelInfoEmpty.displayName = "ChannelInfoEmpty"
const ChannelInfoEmptyIcon = React.forwardRef<
HTMLDivElement,
React.ComponentProps<"div">
>(({ className, ...props }, ref) => (
<div
ref={ref}
aria-hidden="true"
className={cn(
"flex h-14 w-14 items-center justify-center rounded-full bg-newt-bg-elevated text-newt-text-muted",
className
)}
{...props}
/>
))
ChannelInfoEmptyIcon.displayName = "ChannelInfoEmptyIcon"
const ChannelInfoEmptyTitle = React.forwardRef<
HTMLParagraphElement,
React.ComponentProps<"p">
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("font-semibold text-newt-text-primary", className)}
{...props}
/>
))
ChannelInfoEmptyTitle.displayName = "ChannelInfoEmptyTitle"
const ChannelInfoEmptyBody = React.forwardRef<
HTMLParagraphElement,
React.ComponentProps<"p">
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("max-w-[36ch] text-sm text-newt-text-muted", className)}
{...props}
/>
))
ChannelInfoEmptyBody.displayName = "ChannelInfoEmptyBody"
export {
ChannelInfo,
ChannelInfoToolbar,
ChannelInfoActions,
ChannelInfoAction,
ChannelInfoIdentity,
ChannelInfoIcon,
ChannelInfoName,
ChannelInfoType,
ChannelInfoPanel,
ChannelInfoEmpty,
ChannelInfoEmptyIcon,
ChannelInfoEmptyTitle,
ChannelInfoEmptyBody,
}<script setup lang="ts">
import { DialogContent, DialogRoot, DialogTitle } from "reka-ui"
import type { HTMLAttributes } from "vue"
import { computed, useAttrs } from "vue"
import { cn } from "@/lib/utils"
/*
* The panel that slides in over a channel on narrow screens, holding the
* member list, pins, threads and the rest of the channel detail tabs. It is a
* dialog unless it is `inline`.
*
* Reka owns the dialog behaviour: focus moves into the panel, Tab cycles
* through its controls, Escape asks to close it, and a `modal` one takes the
* page behind it out of use. The panel renders in place, with no portal and
* no overlay, so the application decides where it sits. It is open for as
* long as it is mounted. The page beside a dialog that is not modal stays in
* use, so a press or a focus move outside does not close it.
*/
defineOptions({ inheritAttrs: false })
const props = withDefaults(
defineProps<{
class?: HTMLAttributes["class"]
/**
* Render a plain panel: no dialog role, and focus stays where it is. Use
* it for a side panel that is always on screen.
*/
inline?: boolean
/**
* Take the page beside the panel out of use: it is hidden from assistive
* technology, focus cannot move to it, and a press on it closes the
* panel. Use it when the panel covers the channel. Has no effect on an
* `inline` panel.
*/
modal?: boolean
/**
* The accessible name of the panel. Without it, name the panel with
* `aria-label` or `aria-labelledby`.
*/
label?: string
}>(),
{ inline: false, modal: false }
)
const emit = defineEmits<{
/**
* The user asks to close the dialog: Escape, or a press outside a `modal`
* one. Unmount the panel in answer; focus then returns to the element that
* held it before the panel opened.
*/
close: []
}>()
const attrs = useAttrs()
const panelClass =
"flex h-full w-full max-w-sm flex-col overflow-hidden bg-newt-bg-surface text-newt-text-primary"
/*
* Reka always points the dialog at a title. Without a `label` there is none,
* so the reference gives way to whatever name the application passes.
*/
const naming = computed(() =>
props.label === undefined
? { "aria-labelledby": attrs["aria-labelledby"] }
: {}
)
/*
* The dialog has no trigger: the application opens it by mounting it. So the
* panel notes which element holds focus just before it takes it, and hands
* focus back to that element when it unmounts.
*/
let opener: Element | null = null
function rememberOpener() {
opener = document.activeElement
}
function returnFocus(event: Event) {
event.preventDefault()
const element = opener
/*
* A press outside closes a modal panel while the press is still in flight,
* and the browser then moves focus to the page. The timer runs after it.
*/
setTimeout(() => {
if (element instanceof HTMLElement && element.isConnected) element.focus()
}, 0)
}
</script>
<template>
<!-- A name needs a role to hang on: a `div` alone may not carry one. -->
<div
v-if="props.inline"
:role="props.label === undefined ? undefined : 'region'"
:aria-label="props.label"
v-bind="$attrs"
:class="cn(panelClass, props.class)"
>
<slot />
</div>
<DialogRoot
v-else
:open="true"
:modal="props.modal"
@update:open="
(open) => {
if (!open) emit('close')
}
"
>
<DialogContent
v-bind="{ ...$attrs, ...naming }"
:aria-modal="props.modal ? true : undefined"
:aria-describedby="undefined"
:class="cn(panelClass, 'outline-none', props.class)"
@open-auto-focus="rememberOpener"
@close-auto-focus="returnFocus"
@interact-outside="
(event) => {
if (!props.modal) event.preventDefault()
}
"
>
<!-- The name, as a heading no one sees: Reka points the dialog at it. -->
<DialogTitle v-if="props.label !== undefined" class="sr-only">
{{ props.label }}
</DialogTitle>
<slot />
</DialogContent>
</DialogRoot>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<div
:class="
cn(
'flex h-14 shrink-0 items-center justify-between gap-2 px-2',
props.class
)
"
>
<slot />
</div>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<div :class="cn('flex items-center gap-1', props.class)">
<slot />
</div>
</template><script setup lang="ts">
import type { Component, HTMLAttributes } from "vue"
import { computed } from "vue"
import { cn } from "@/lib/utils"
defineOptions({ inheritAttrs: false })
/*
* The `span` form runs nothing: it drops every listener, so a click cannot
* start an action that the keyboard and assistive technology miss.
*/
function withoutListeners(attrs: HTMLAttributes): HTMLAttributes {
return Object.fromEntries(
Object.entries(attrs).filter(([name]) => !/^on[A-Z]/.test(name))
)
}
const props = defineProps<{
/**
* The element or component to render. Defaults to `button`, or to `a`
* when `href` is set; pass `NuxtLink` or `RouterLink` to keep client
* navigation. `span` renders the decorative form: hidden from assistive
* technology, out of the tab order, with no pointer and no hover.
* Its event handlers do not run.
*/
as?: string | Component
/** Render a link to this URL. */
href?: string
/**
* Turns the control off. A link loses its URL, which takes it out of the
* tab order, and says so with `aria-disabled`.
*/
disabled?: boolean
class?: HTMLAttributes["class"]
}>()
const tag = computed(
() => props.as ?? (props.href === undefined ? "button" : "a")
)
const isButton = computed(() => tag.value === "button")
const decorative = computed(() => tag.value === "span")
</script>
<template>
<component
:is="tag"
:type="isButton ? 'button' : undefined"
:href="decorative || props.disabled ? undefined : props.href"
:disabled="isButton ? props.disabled : undefined"
:aria-disabled="
!isButton && !decorative && props.disabled ? true : undefined
"
:aria-hidden="decorative ? true : undefined"
:class="
cn(
'inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-newt-text-secondary no-underline',
!decorative &&
'cursor-pointer transition-colors duration-fast ease-newt hover:bg-newt-bg-hover hover:text-newt-text-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-newt-text-link disabled:cursor-not-allowed disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:cursor-not-allowed aria-disabled:opacity-50',
props.class
)
"
v-bind="decorative ? withoutListeners($attrs) : $attrs"
>
<slot />
</component>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<div :class="cn('flex min-w-0 items-center gap-3 px-4 pb-3', props.class)">
<slot />
</div>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<div
aria-hidden="true"
:class="
cn(
'flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-newt-bg-elevated text-lg font-bold leading-none text-newt-text-muted',
props.class
)
"
>
<slot>#</slot>
</div>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<div :class="cn('truncate font-bold text-newt-text-primary', props.class)">
<slot />
</div>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<div :class="cn('text-[13px] text-newt-text-muted', props.class)">
<slot />
</div>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<!-- Scrolling area under the tab strip. -->
<div :class="cn('min-h-0 flex-1 overflow-y-auto px-2 pb-4', props.class)">
<slot />
</div>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<div
:class="
cn('flex flex-col items-center gap-2 px-6 py-10 text-center', props.class)
"
>
<slot />
</div>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<div
aria-hidden="true"
:class="
cn(
'flex h-14 w-14 items-center justify-center rounded-full bg-newt-bg-elevated text-newt-text-muted',
props.class
)
"
>
<slot />
</div>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<p :class="cn('font-semibold text-newt-text-primary', props.class)">
<slot />
</p>
</template><script setup lang="ts">
import type { HTMLAttributes } from "vue"
import { cn } from "@/lib/utils"
const props = defineProps<{ class?: HTMLAttributes["class"] }>()
</script>
<template>
<p :class="cn('max-w-[36ch] text-sm text-newt-text-muted', props.class)">
<slot />
</p>
</template>export { default as ChannelInfo } from "./ChannelInfo.vue"
export { default as ChannelInfoToolbar } from "./ChannelInfoToolbar.vue"
export { default as ChannelInfoActions } from "./ChannelInfoActions.vue"
export { default as ChannelInfoAction } from "./ChannelInfoAction.vue"
export { default as ChannelInfoIdentity } from "./ChannelInfoIdentity.vue"
export { default as ChannelInfoIcon } from "./ChannelInfoIcon.vue"
export { default as ChannelInfoName } from "./ChannelInfoName.vue"
export { default as ChannelInfoType } from "./ChannelInfoType.vue"
export { default as ChannelInfoPanel } from "./ChannelInfoPanel.vue"
export { default as ChannelInfoEmpty } from "./ChannelInfoEmpty.vue"
export { default as ChannelInfoEmptyIcon } from "./ChannelInfoEmptyIcon.vue"
export { default as ChannelInfoEmptyTitle } from "./ChannelInfoEmptyTitle.vue"
export { default as ChannelInfoEmptyBody } from "./ChannelInfoEmptyBody.vue"Update the import paths
The files import @/lib/utils and sibling components through the aliases in your components.json. Point them at wherever those live in your project.
No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Channel Info to your React project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.
No CLI, no components.json: paste this into Claude, Cursor, Copilot or any coding assistant and it adds Channel Info to your Vue project by hand. The prompt carries the source of every file the CLI would write — this component's and those of the components it builds on — with the imports already pointed at the default aliases.
Usage
import { ChannelInfo } from "@/components/ui/channel-info"
export function Example() {
return <ChannelInfo />
}<script setup lang="ts">
import { ChannelInfo, ChannelInfoToolbar, ChannelInfoActions, ChannelInfoAction, ChannelInfoIdentity, ChannelInfoIcon, ChannelInfoName, ChannelInfoType, ChannelInfoPanel, ChannelInfoEmpty, ChannelInfoEmptyIcon, ChannelInfoEmptyTitle, ChannelInfoEmptyBody } from "@/components/ui/channel-info"
</script>
<template>
<ChannelInfo />
</template>The preview above is an inline panel: a side panel that is always on screen. Without inline, ChannelInfo is a dialog.
Examples
Dialog
ChannelInfo is a dialog built on Radix Dialog in React and Reka UI Dialog in Vue. It renders in place, with no portal and no overlay, so your layout decides where it sits. It is open for as long as it is mounted.
When it mounts, focus moves to its first control. Tab cycles through the controls of the panel. Escape calls onClose (@close in Vue). Unmount the panel in answer. Focus then returns to the element that held it before.
Add modal when the panel covers the channel, as the example below does. The rest of the page is then out of use. Assistive technology skips it, focus cannot move to it, and a press on it asks to close the panel.
newt-channel-info"use client"
import * as React from "react"
import { Button } from "@/registry/bases/newt/ui/button"
import {
ChannelInfo,
ChannelInfoAction,
ChannelInfoEmpty,
ChannelInfoEmptyBody,
ChannelInfoEmptyTitle,
ChannelInfoIcon,
ChannelInfoIdentity,
ChannelInfoName,
ChannelInfoPanel,
ChannelInfoToolbar,
ChannelInfoType,
} from "@/registry/bases/newt/ui/channel-info"
export default function ChannelInfoDialogDemo() {
const [open, setOpen] = React.useState(false)
return (
<div className="relative flex h-[320px] w-full max-w-sm items-center justify-center overflow-hidden rounded-md bg-newt-bg-elevated">
<Button variant="secondary" onClick={() => setOpen(true)}>
Channel details
</Button>
{open ? (
<ChannelInfo
modal
label="Channel information for #general"
onClose={() => setOpen(false)}
className="absolute inset-0"
>
<ChannelInfoToolbar>
<ChannelInfoAction
aria-label="Back to channel"
onClick={() => setOpen(false)}
>
<svg viewBox="0 0 20 20" className="h-5 w-5" fill="currentColor">
<path d="M8.7 3.3 2 10l6.7 6.7 1.4-1.4L5.8 11H18V9H5.8l4.3-4.3-1.4-1.4Z" />
</svg>
</ChannelInfoAction>
</ChannelInfoToolbar>
<ChannelInfoIdentity>
<ChannelInfoIcon />
<div className="min-w-0">
<ChannelInfoName>general</ChannelInfoName>
<ChannelInfoType>Text Channel</ChannelInfoType>
</div>
</ChannelInfoIdentity>
<ChannelInfoPanel>
<ChannelInfoEmpty>
<ChannelInfoEmptyTitle>
No pinned messages yet.
</ChannelInfoEmptyTitle>
<ChannelInfoEmptyBody>
Press Escape or the back arrow to return to the channel.
</ChannelInfoEmptyBody>
</ChannelInfoEmpty>
</ChannelInfoPanel>
</ChannelInfo>
) : null}
</div>
)
}<script setup lang="ts">
import { ref } from "vue"
import { Button } from "~~/registry/bases/newt/ui/button"
import {
ChannelInfo,
ChannelInfoAction,
ChannelInfoEmpty,
ChannelInfoEmptyBody,
ChannelInfoEmptyTitle,
ChannelInfoIcon,
ChannelInfoIdentity,
ChannelInfoName,
ChannelInfoPanel,
ChannelInfoToolbar,
ChannelInfoType,
} from "~~/registry/bases/newt/ui/channel-info"
const open = ref(false)
</script>
<template>
<div
class="relative flex h-[320px] w-full max-w-sm items-center justify-center overflow-hidden rounded-md bg-newt-bg-elevated"
>
<Button variant="secondary" @click="open = true">Channel details</Button>
<ChannelInfo
v-if="open"
modal
label="Channel information for #general"
class="absolute inset-0"
@close="open = false"
>
<ChannelInfoToolbar>
<ChannelInfoAction aria-label="Back to channel" @click="open = false">
<svg viewBox="0 0 20 20" class="h-5 w-5" fill="currentColor">
<path
d="M8.7 3.3 2 10l6.7 6.7 1.4-1.4L5.8 11H18V9H5.8l4.3-4.3-1.4-1.4Z"
/>
</svg>
</ChannelInfoAction>
</ChannelInfoToolbar>
<ChannelInfoIdentity>
<ChannelInfoIcon />
<div class="min-w-0">
<ChannelInfoName>general</ChannelInfoName>
<ChannelInfoType>Text Channel</ChannelInfoType>
</div>
</ChannelInfoIdentity>
<ChannelInfoPanel>
<ChannelInfoEmpty>
<ChannelInfoEmptyTitle>No pinned messages yet.</ChannelInfoEmptyTitle>
<ChannelInfoEmptyBody>
Press Escape or the back arrow to return to the channel.
</ChannelInfoEmptyBody>
</ChannelInfoEmpty>
</ChannelInfoPanel>
</ChannelInfo>
</div>
</template>Decorative actions
A read-only view draws the actions and does nothing with them. Pass as="span" to ChannelInfoAction. The action keeps its look and loses its pointer, its hover and its place in the tab order. It also takes aria-hidden.
API reference
ChannelInfo
inline?boolean | undefined
Render a plain panel: no dialog role, and focus stays where it is. Use it for a side panel that is always on screen.
boolean | undefinedfalsemodal?boolean | undefined
Take the page beside the panel out of use: it is hidden from assistive technology, focus cannot move to it, and a press on it closes the panel. Use it when the panel covers the channel. Has no effect on an `inline` panel.
boolean | undefinedfalselabel?string | undefined
The accessible name of the panel. Without it, name the panel with `aria-label` or `aria-labelledby`.
string | undefinedonClose / @close?() => void
The user asks to close the dialog: Escape, or a press outside a `modal` one.
() => voidChannelInfoAction
as?string | Component
The element or component to render. Defaults to `button`, or to `a` when `href` is set. Pass a router link component to keep client navigation. `span` renders the decorative form, which runs no event handlers.
string | Componenthref?string | undefined
Render a link to this URL.
string | undefineddisabled?boolean | undefined
Turns the control off. A link loses its URL, which takes it out of the tab order, and says so with `aria-disabled`. A disabled control fades to half opacity.
boolean | undefinedThe registry exports ChannelInfo, ChannelInfoToolbar, ChannelInfoActions, ChannelInfoAction, ChannelInfoIdentity, ChannelInfoIcon, ChannelInfoName, ChannelInfoType, ChannelInfoPanel, ChannelInfoEmpty, ChannelInfoEmptyIcon, ChannelInfoEmptyTitle, ChannelInfoEmptyBody. Parts without a table accept the native attributes for the element they render; React uses className, while Vue uses class and fallthrough attributes.
Accessibility
Give the panel a label. A dialog reads it when it opens. An inline panel with a label is a region landmark; without one it is a plain div.
Tab cycles through the controls of a dialog, and Escape leaves it. A dialog that is not modal leaves the page beside it in use: a press there moves focus out, and the panel stays open. Use modal when the panel hides the channel, so focus cannot move to content the user cannot see.
Do not wrap a dialog ChannelInfo in a Drawer or a Modal. That nests one dialog in another. Put an inline panel inside them when you want their overlay.
Every icon-only action needs an aria-label. Any interactive child needs a visible focus indicator, and meaning must not rely on colour alone.
In the plain HTML and CSS distribution, channel-info.js gives a panel marked data-newt-channel-info the same behaviour. A data-newt-channel-info-close control closes it, and aria-modal="true" makes it modal. The panel fires newt:close before it leaves the page; cancel the event to close it your own way.
With several panels open, Escape closes the newest one that holds focus. An Escape that a control inside already handled with preventDefault() closes nothing, and the panel marks the Escape it handles the same way. Tab skips controls inside hidden content.
Tokens
Channel Info reads its colours, radii and motion from the --newt-* tokens installed with the library. Override a token and every component that reads it follows, including this one — see the token layer. In the plain HTML and CSS distribution the same component is newt-channel-info.
--newt-bg-surface--newt-text-primary--newt-radius-full--newt-text-secondary--newt-duration-fast--newt-ease--newt-bg-hover--newt-text-link--newt-bg-elevated--newt-text-muted