Channel sidebar
The column a server is navigated from: its name, its channels as a tree and the user panel at the foot.
The navigation column of a chat-shaped app, assembled from the registry: the server’s name, its categories and channels as a Tree, and the signed-in user’s User Panel pinned to the bottom. The channel list scrolls; the header and the panel stay put.
Give it a height, and pair it with the Chat window block for a whole screen.
"use client"
import * as React from "react"
import { ChannelSidebar } from "@/registry/bases/newt/blocks/channel-sidebar/channel-sidebar"
import type { TreeNode } from "@/registry/bases/newt/ui/tree"
/* Placeholder names: no real account, and no Discord asset. */
const CHANNELS: readonly TreeNode[] = [
{
id: "text",
label: "Text channels",
children: [
{ id: "general", label: "general", prefix: "#" },
{ id: "help", label: "help", prefix: "#", badge: 3 },
{ id: "release-notes", label: "release-notes", prefix: "#" },
],
},
{
id: "voice",
label: "Voice channels",
children: [{ id: "lounge", label: "Lounge", prefix: "🔊" }],
},
]
export default function ChannelSidebarDemo() {
const [channel, setChannel] = React.useState("general")
return (
<ChannelSidebar
className="h-[420px] w-64"
serverName="Build Club"
channels={CHANNELS}
defaultExpanded={["text", "voice"]}
channel={channel}
onChannelChange={setChannel}
user={{
name: "ada",
initials: "A",
status: "online",
statusText: "Online",
}}
/>
)
}<script setup lang="ts">
import { ref } from "vue"
import { ChannelSidebar } from "~~/registry/bases/newt/blocks/channel-sidebar"
import type { TreeNode } from "~~/registry/bases/newt/ui/tree"
/* Placeholder names: no real account, and no Discord asset. */
const CHANNELS: readonly TreeNode[] = [
{
id: "text",
label: "Text channels",
children: [
{ id: "general", label: "general", prefix: "#" },
{ id: "help", label: "help", prefix: "#", badge: 3 },
{ id: "release-notes", label: "release-notes", prefix: "#" },
],
},
{
id: "voice",
label: "Voice channels",
children: [{ id: "lounge", label: "Lounge", prefix: "🔊" }],
},
]
const channel = ref("general")
</script>
<template>
<ChannelSidebar
v-model:channel="channel"
class="h-[420px] w-64"
server-name="Build Club"
:channels="CHANNELS"
:default-expanded="['text', 'voice']"
:user="{
name: 'ada',
initials: 'A',
status: 'online',
statusText: 'Online',
}"
/>
</template>Installation
npx newtui@latest add channel-sidebarnpx shadcn@latest add @newtui/channel-sidebarnpx shadcn-vue@latest add @newtui/channel-sidebarpnpm dlx newtui@latest add channel-sidebarpnpm dlx shadcn@latest add @newtui/channel-sidebarpnpm dlx shadcn-vue@latest add @newtui/channel-sidebaryarn dlx newtui@latest add channel-sidebaryarn dlx shadcn@latest add @newtui/channel-sidebaryarn dlx shadcn-vue@latest add @newtui/channel-sidebarbunx newtui@latest add channel-sidebarbunx shadcn@latest add @newtui/channel-sidebarbunx shadcn-vue@latest add @newtui/channel-sidebardeno run -A npm:newtui@latest add channel-sidebardeno run -A npm:shadcn@latest add @newtui/channel-sidebardeno run -A npm:shadcn-vue@latest add @newtui/channel-sidebarvlx newtui@latest add channel-sidebarvlx shadcn@latest add @newtui/channel-sidebarvlx shadcn-vue@latest add @newtui/channel-sidebarvp dlx newtui@latest add channel-sidebarvp dlx shadcn@latest add @newtui/channel-sidebarvp dlx shadcn-vue@latest add @newtui/channel-sidebarnubx newtui@latest add channel-sidebarnubx shadcn@latest add @newtui/channel-sidebarnubx shadcn-vue@latest add @newtui/channel-sidebarnlx newtui@latest add channel-sidebarnlx shadcn@latest add @newtui/channel-sidebarnlx shadcn-vue@latest add @newtui/channel-sidebarupx newtui@latest add channel-sidebarupx shadcn@latest add @newtui/channel-sidebarupx shadcn-vue@latest add @newtui/channel-sidebar- 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.
Add the components it builds on
Copy the source into your project
"use client"
import * as React from "react"
import { cn } from "@/lib/utils"
import { Avatar } from "@/registry/bases/newt/ui/avatar"
import {
StatusDot,
StatusIndicator,
} from "@/registry/bases/newt/ui/status-indicator"
import type { StatusDotProps } from "@/registry/bases/newt/ui/status-indicator"
import { Tree, type TreeNode } from "@/registry/bases/newt/ui/tree"
import {
UserPanel,
UserPanelActions,
UserPanelButton,
UserPanelInfo,
} from "@/registry/bases/newt/ui/user-panel"
/*
* The shape the sidebar reads. A block does not know your data layer; map
* onto this at the edge of it.
*/
export interface SidebarUser {
name: string
initials: string
status: NonNullable<StatusDotProps["status"]>
/** The line under the name. */
statusText?: string
}
/*
* The state of the dot in words, for a screen reader. The dot speaks it only
* when no status line is written beside it.
*/
const STATUS_LABELS = {
online: "Online",
idle: "Idle",
dnd: "Do not disturb",
offline: "Offline",
streaming: "Streaming",
} as const satisfies Record<SidebarUser["status"], string>
export interface ChannelSidebarProps extends Omit<
React.ComponentProps<"aside">,
"onChange"
> {
serverName: string
/** Categories and their channels, as the tree takes them. */
channels: readonly TreeNode[]
/** Ids of the categories that start open. */
defaultExpanded?: readonly string[]
/** The id of the channel being shown. */
channel?: string
onChannelChange?: (channel: string) => void
user: SidebarUser
/** Called when the settings button in the user panel is pressed. */
onOpenSettings?: () => void
}
/*
* The column a server is navigated from: its name, its channels as a tree and
* the signed-in user's controls pinned to the foot. Muting and deafening are
* kept here as local state because the block has no voice connection to tell;
* lift them when yours does.
*/
export function ChannelSidebar({
serverName,
channels,
defaultExpanded,
channel,
onChannelChange,
user,
onOpenSettings,
className,
...props
}: ChannelSidebarProps) {
const [muted, setMuted] = React.useState(false)
const [deafened, setDeafened] = React.useState(false)
return (
<aside
aria-label={`${serverName} channels`}
className={cn(
"flex h-full min-h-0 flex-col bg-newt-bg-surface",
className
)}
{...props}
>
<header className="border-b border-newt-border px-4 py-3 text-[15px] font-semibold leading-5 text-newt-text-primary">
<span className="block truncate">{serverName}</span>
</header>
<div className="min-h-0 flex-1 overflow-y-auto p-2">
<Tree
label="Channels"
items={channels}
defaultExpanded={defaultExpanded}
value={channel}
onValueChange={onChannelChange}
/>
</div>
<div className="p-2">
<UserPanel>
<StatusIndicator>
<Avatar size="sm">{user.initials}</Avatar>
<StatusDot
status={user.status}
label={
user.statusText === undefined
? STATUS_LABELS[user.status]
: undefined
}
/>
</StatusIndicator>
<UserPanelInfo name={user.name} status={user.statusText} />
<UserPanelActions>
<UserPanelButton
icon="microphone"
label="Mute"
pressed={muted}
onPressedChange={setMuted}
/>
<UserPanelButton
icon="headphones"
label="Deafen"
pressed={deafened}
onPressedChange={setDeafened}
/>
<UserPanelButton
icon="settings"
label="User settings"
onClick={onOpenSettings}
/>
</UserPanelActions>
</UserPanel>
</div>
</aside>
)
}<script setup lang="ts">
import { ref, type HTMLAttributes } from "vue"
import { Avatar } from "~~/registry/bases/newt/ui/avatar"
import {
StatusDot,
StatusIndicator,
} from "~~/registry/bases/newt/ui/status-indicator"
import { Tree, type TreeNode } from "~~/registry/bases/newt/ui/tree"
import {
UserPanel,
UserPanelActions,
UserPanelButton,
UserPanelInfo,
} from "~~/registry/bases/newt/ui/user-panel"
import { cn } from "@/lib/utils"
import type { SidebarUser, UserStatus } from "./types"
/*
* The state of the dot in words, for a screen reader. The dot speaks it only
* when no status line is written beside it.
*/
const STATUS_LABELS = {
online: "Online",
idle: "Idle",
dnd: "Do not disturb",
offline: "Offline",
streaming: "Streaming",
} as const satisfies Record<UserStatus, string>
/*
* The column a server is navigated from: its name, its channels as a tree and
* the signed-in user's controls pinned to the foot. Muting and deafening are
* kept here as local state because the block has no voice connection to tell;
* lift them when yours does.
*/
const props = defineProps<{
class?: HTMLAttributes["class"]
serverName: string
/** Categories and their channels, as the tree takes them. */
channels: readonly TreeNode[]
/** Ids of the categories that start open. */
defaultExpanded?: readonly string[]
user: SidebarUser
}>()
const emit = defineEmits<{
/** Fired when the settings button in the user panel is pressed. */
(e: "openSettings"): void
}>()
/** The id of the channel being shown. */
const channel = defineModel<string>("channel")
const muted = ref(false)
const deafened = ref(false)
</script>
<template>
<aside
:aria-label="`${props.serverName} channels`"
:class="cn('flex h-full min-h-0 flex-col bg-newt-bg-surface', props.class)"
>
<header
class="border-b border-newt-border px-4 py-3 text-[15px] font-semibold leading-5 text-newt-text-primary"
>
<span class="block truncate">{{ props.serverName }}</span>
</header>
<div class="min-h-0 flex-1 overflow-y-auto p-2">
<Tree
v-model="channel"
label="Channels"
:items="props.channels"
:default-expanded="props.defaultExpanded"
/>
</div>
<div class="p-2">
<UserPanel>
<StatusIndicator>
<Avatar size="sm">{{ props.user.initials }}</Avatar>
<StatusDot
:status="props.user.status"
:label="
props.user.statusText === undefined
? STATUS_LABELS[props.user.status]
: undefined
"
/>
</StatusIndicator>
<UserPanelInfo
:name="props.user.name"
:status="props.user.statusText"
/>
<UserPanelActions>
<UserPanelButton
v-model:pressed="muted"
icon="microphone"
label="Mute"
/>
<UserPanelButton
v-model:pressed="deafened"
icon="headphones"
label="Deafen"
/>
<UserPanelButton
icon="settings"
label="User settings"
@click="emit('openSettings')"
/>
</UserPanelActions>
</UserPanel>
</div>
</aside>
</template>export type UserStatus = "online" | "idle" | "dnd" | "offline" | "streaming"
/*
* The shape the sidebar reads. A block does not know your data layer; map
* onto this at the edge of it.
*/
export interface SidebarUser {
name: string
initials: string
status: UserStatus
/** The line under the name. */
statusText?: string
}export { default as ChannelSidebar } from "./ChannelSidebar.vue"
export type { SidebarUser, UserStatus } from "./types"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 sidebar 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 sidebar 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 { ChannelSidebar } from "@/components/channel-sidebar"
export function Example() {
return <ChannelSidebar />
}<script setup lang="ts">
import { ChannelSidebar } from "@/components/channel-sidebar"
</script>
<template>
<ChannelSidebar />
</template>API reference
ChannelSidebar
serverName?string
Shown in the header and used to name the region.
stringchannels?TreeNode[]
Categories and their channels, in the shape the tree takes.
TreeNode[]defaultExpanded?string[]
Ids of the categories that start open.
string[]channel / v-model:channel?string
The id of the channel being shown.
stringonChannelChange?(channel: string) => void
React only. Called when a channel is chosen; Vue emits `update:channel`.
(channel: string) => voiduser?{ name: string; initials: string; status: Status; statusText?: string }
The signed-in user, for the panel at the foot.
{ name: string; initials: string; status: Status; statusText?: string }onOpenSettings / @open-settings?() => void
Called when the settings button in the user panel is pressed.
() => voidMute and deafen are local state inside the block, because it has no voice connection to tell. When yours does, copy the block and lift those two values out.
Accessibility
The column is an <aside> named after the server. Inside it the channels are one tab stop with the tree’s arrow-key model, and the user panel’s buttons follow in the tab order. See the Tree and User Panel pages for the detail of each.
Tokens
Channel sidebar 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.