Sidebar
When you need to move from a horizontal nav to a sidebar, you know your app is all grown up.
import { Avatar } from '@/components/avatar'
import {
Dropdown,
DropdownButton,
DropdownDivider,
DropdownItem,
DropdownLabel,
DropdownMenu,
} from '@/components/dropdown'
import {
Sidebar,
SidebarBody,
SidebarFooter,
SidebarHeader,
SidebarItem,
SidebarLabel,
SidebarSection,
SidebarSpacer,
} from '@/components/sidebar'
import {
ArrowRightStartOnRectangleIcon,
ChevronDownIcon,
ChevronUpIcon,
Cog8ToothIcon,
LightBulbIcon,
PlusIcon,
ShieldCheckIcon,
UserIcon,
} from '@heroicons/react/16/solid'
import {
Cog6ToothIcon,
HomeIcon,
InboxIcon,
MagnifyingGlassIcon,
MegaphoneIcon,
QuestionMarkCircleIcon,
SparklesIcon,
Square2StackIcon,
TicketIcon,
} from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarHeader>
<Dropdown>
<DropdownButton as={SidebarItem} className="mb-2.5">
<Avatar src="/tailwind-logo.svg" />
<SidebarLabel>Tailwind Labs</SidebarLabel>
<ChevronDownIcon />
</DropdownButton>
<DropdownMenu className="min-w-64" anchor="bottom start">
<DropdownItem href="/teams/1/settings">
<Cog8ToothIcon />
<DropdownLabel>Settings</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/teams/1">
<Avatar slot="icon" src="/tailwind-logo.svg" />
<DropdownLabel>Tailwind Labs</DropdownLabel>
</DropdownItem>
<DropdownItem href="/teams/2">
<Avatar slot="icon" initials="WC" className="bg-purple-500 text-white" />
<DropdownLabel>Workcation</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/teams/create">
<PlusIcon />
<DropdownLabel>New team…</DropdownLabel>
</DropdownItem>
</DropdownMenu>
</Dropdown>
<SidebarSection>
<SidebarItem href="/search">
<MagnifyingGlassIcon />
<SidebarLabel>Search</SidebarLabel>
</SidebarItem>
<SidebarItem href="/inbox">
<InboxIcon />
<SidebarLabel>Inbox</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarHeader>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/home">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
<SidebarSpacer />
<SidebarSection>
<SidebarItem href="/support">
<QuestionMarkCircleIcon />
<SidebarLabel>Support</SidebarLabel>
</SidebarItem>
<SidebarItem href="/changelog">
<SparklesIcon />
<SidebarLabel>Changelog</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
<SidebarFooter>
<Dropdown>
<DropdownButton as={SidebarItem}>
<span className="flex min-w-0 items-center gap-3">
<Avatar src="/profile-photo.jpg" className="size-10" square alt="" />
<span className="min-w-0">
<span className="block truncate text-sm/5 font-medium text-zinc-950 dark:text-white">Erica</span>
<span className="block truncate text-xs/5 font-normal text-zinc-500 dark:text-zinc-400">
erica@example.com
</span>
</span>
</span>
<ChevronUpIcon />
</DropdownButton>
<DropdownMenu className="min-w-64" anchor="top start">
<DropdownItem href="/my-profile">
<UserIcon />
<DropdownLabel>My profile</DropdownLabel>
</DropdownItem>
<DropdownItem href="/settings">
<Cog8ToothIcon />
<DropdownLabel>Settings</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/privacy-policy">
<ShieldCheckIcon />
<DropdownLabel>Privacy policy</DropdownLabel>
</DropdownItem>
<DropdownItem href="/share-feedback">
<LightBulbIcon />
<DropdownLabel>Share feedback</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/logout">
<ArrowRightStartOnRectangleIcon />
<DropdownLabel>Sign out</DropdownLabel>
</DropdownItem>
</DropdownMenu>
</Dropdown>
</SidebarFooter>
</Sidebar>
)
}
import { Avatar } from '@/components/avatar'
import {
Dropdown,
DropdownButton,
DropdownDivider,
DropdownItem,
DropdownLabel,
DropdownMenu,
} from '@/components/dropdown'
import {
Sidebar,
SidebarBody,
SidebarFooter,
SidebarHeader,
SidebarItem,
SidebarLabel,
SidebarSection,
SidebarSpacer,
} from '@/components/sidebar'
import {
ArrowRightStartOnRectangleIcon,
ChevronDownIcon,
ChevronUpIcon,
Cog8ToothIcon,
LightBulbIcon,
PlusIcon,
ShieldCheckIcon,
UserIcon,
} from '@heroicons/react/16/solid'
import {
Cog6ToothIcon,
HomeIcon,
InboxIcon,
MagnifyingGlassIcon,
MegaphoneIcon,
QuestionMarkCircleIcon,
SparklesIcon,
Square2StackIcon,
TicketIcon,
} from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarHeader>
<Dropdown>
<DropdownButton as={SidebarItem} className="mb-2.5">
<Avatar src="/tailwind-logo.svg" />
<SidebarLabel>Tailwind Labs</SidebarLabel>
<ChevronDownIcon />
</DropdownButton>
<DropdownMenu className="min-w-64" anchor="bottom start">
<DropdownItem href="/teams/1/settings">
<Cog8ToothIcon />
<DropdownLabel>Settings</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/teams/1">
<Avatar slot="icon" src="/tailwind-logo.svg" />
<DropdownLabel>Tailwind Labs</DropdownLabel>
</DropdownItem>
<DropdownItem href="/teams/2">
<Avatar slot="icon" initials="WC" className="bg-purple-500 text-white" />
<DropdownLabel>Workcation</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/teams/create">
<PlusIcon />
<DropdownLabel>New team…</DropdownLabel>
</DropdownItem>
</DropdownMenu>
</Dropdown>
<SidebarSection>
<SidebarItem href="/search">
<MagnifyingGlassIcon />
<SidebarLabel>Search</SidebarLabel>
</SidebarItem>
<SidebarItem href="/inbox">
<InboxIcon />
<SidebarLabel>Inbox</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarHeader>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/home">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
<SidebarSpacer />
<SidebarSection>
<SidebarItem href="/support">
<QuestionMarkCircleIcon />
<SidebarLabel>Support</SidebarLabel>
</SidebarItem>
<SidebarItem href="/changelog">
<SparklesIcon />
<SidebarLabel>Changelog</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
<SidebarFooter>
<Dropdown>
<DropdownButton as={SidebarItem}>
<span className="flex min-w-0 items-center gap-3">
<Avatar src="/profile-photo.jpg" className="size-10" square alt="" />
<span className="min-w-0">
<span className="block truncate text-sm/5 font-medium text-zinc-950 dark:text-white">Erica</span>
<span className="block truncate text-xs/5 font-normal text-zinc-500 dark:text-zinc-400">
erica@example.com
</span>
</span>
</span>
<ChevronUpIcon />
</DropdownButton>
<DropdownMenu className="min-w-64" anchor="top start">
<DropdownItem href="/my-profile">
<UserIcon />
<DropdownLabel>My profile</DropdownLabel>
</DropdownItem>
<DropdownItem href="/settings">
<Cog8ToothIcon />
<DropdownLabel>Settings</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/privacy-policy">
<ShieldCheckIcon />
<DropdownLabel>Privacy policy</DropdownLabel>
</DropdownItem>
<DropdownItem href="/share-feedback">
<LightBulbIcon />
<DropdownLabel>Share feedback</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/logout">
<ArrowRightStartOnRectangleIcon />
<DropdownLabel>Sign out</DropdownLabel>
</DropdownItem>
</DropdownMenu>
</Dropdown>
</SidebarFooter>
</Sidebar>
)
}
Component API
Prop | Default | Description |
---|---|---|
Sidebar | ||
This component does not expose any component-specific props. | ||
SidebarHeader extends the JSX <div> element | ||
This component does not expose any component-specific props. | ||
SidebarBody extends the JSX <nav> element | ||
This component does not expose any component-specific props. | ||
SidebarFooter extends the JSX <div> element | ||
This component does not expose any component-specific props. | ||
SidebarSection extends the JSX <div> element | ||
This component does not expose any component-specific props. | ||
SidebarDivider extends the JSX <hr> element | ||
This component does not expose any component-specific props. | ||
SidebarSpacer extends the JSX <div> element | ||
This component does not expose any component-specific props. | ||
SidebarHeading extends the JSX <div> element | ||
This component does not expose any component-specific props. | ||
SidebarItem extends the Headless UI Button component or the Link component | ||
current | - | Whether or not it is the current navigation item. |
href | - | The target URL when using the button as a link. |
SidebarLabel extends the JSX <span> element | ||
This component does not expose any component-specific props. |
Examples
Basic example
Use the Sidebar
, SidebarBody
, SidebarSection
, and SidebarItem
components to build a basic sidebar:
import { Sidebar, SidebarBody, SidebarItem, SidebarSection } from '@/components/sidebar'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">Home</SidebarItem>
<SidebarItem href="/events">Events</SidebarItem>
<SidebarItem href="/orders">Orders</SidebarItem>
<SidebarItem href="/broadcasts">Broadcasts</SidebarItem>
<SidebarItem href="/settings">Settings</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
import { Sidebar, SidebarBody, SidebarItem, SidebarSection } from '@/components/sidebar'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">Home</SidebarItem>
<SidebarItem href="/events">Events</SidebarItem>
<SidebarItem href="/orders">Orders</SidebarItem>
<SidebarItem href="/broadcasts">Broadcasts</SidebarItem>
<SidebarItem href="/settings">Settings</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
With logo
Add your own logo as an image or component to your sidebar, using utility classes to fine-tune the layout to suit your logo:
import { Link } from '@/components/link'
import { Sidebar, SidebarBody, SidebarItem, SidebarSection } from '@/components/sidebar'
import { Logo } from './logo'
function Example() {
return (
<Sidebar>
<SidebarBody>
<div className="mb-2 flex">
<Link href="#" aria-label="Home">
<Logo />
</Link>
</div>
<SidebarSection>
<SidebarItem href="/">Home</SidebarItem>
<SidebarItem href="/events">Events</SidebarItem>
<SidebarItem href="/orders">Orders</SidebarItem>
<SidebarItem href="/broadcasts">Broadcasts</SidebarItem>
<SidebarItem href="/settings">Settings</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
import { Link } from '@/components/link'
import { Sidebar, SidebarBody, SidebarItem, SidebarSection } from '@/components/sidebar'
import { Logo } from './logo'
function Example() {
return (
<Sidebar>
<SidebarBody>
<div className="mb-2 flex">
<Link href="#" aria-label="Home">
<Logo />
</Link>
</div>
<SidebarSection>
<SidebarItem href="/">Home</SidebarItem>
<SidebarItem href="/events">Events</SidebarItem>
<SidebarItem href="/orders">Orders</SidebarItem>
<SidebarItem href="/broadcasts">Broadcasts</SidebarItem>
<SidebarItem href="/settings">Settings</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
With icons
Add an icon as the first child of a SidebarItem
to render it next to the link text:
import { Sidebar, SidebarBody, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import { Cog6ToothIcon, HomeIcon, MegaphoneIcon, Square2StackIcon, TicketIcon } from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
import { Sidebar, SidebarBody, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import { Cog6ToothIcon, HomeIcon, MegaphoneIcon, Square2StackIcon, TicketIcon } from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
The SidebarItem
component is designed to work best with 20×20 icons.
With active state
Use the current
prop to specify which SidebarItem
is the current navigation item:
import { Sidebar, SidebarBody, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import { Cog6ToothIcon, HomeIcon, MegaphoneIcon, Square2StackIcon, TicketIcon } from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/" current>
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
import { Sidebar, SidebarBody, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import { Cog6ToothIcon, HomeIcon, MegaphoneIcon, Square2StackIcon, TicketIcon } from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/" current>
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
With sticky header
Use the SidebarHeader
component before the SidebarBody
component to add a sticky header to the sidebar:
import { Sidebar, SidebarBody, SidebarHeader, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import {
Cog6ToothIcon,
HomeIcon,
InboxIcon,
MagnifyingGlassIcon,
MegaphoneIcon,
Square2StackIcon,
TicketIcon,
} from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarHeader>
<SidebarSection>
<SidebarItem href="/search">
<MagnifyingGlassIcon />
<SidebarLabel>Search</SidebarLabel>
</SidebarItem>
<SidebarItem href="/inbox">
<InboxIcon />
<SidebarLabel>Inbox</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarHeader>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
import { Sidebar, SidebarBody, SidebarHeader, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import {
Cog6ToothIcon,
HomeIcon,
InboxIcon,
MagnifyingGlassIcon,
MegaphoneIcon,
Square2StackIcon,
TicketIcon,
} from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarHeader>
<SidebarSection>
<SidebarItem href="/search">
<MagnifyingGlassIcon />
<SidebarLabel>Search</SidebarLabel>
</SidebarItem>
<SidebarItem href="/inbox">
<InboxIcon />
<SidebarLabel>Inbox</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarHeader>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
With sticky footer
Use the SidebarFooter
component after the SidebarBody
component to add a sticky footer to the sidebar:
import { Avatar } from '@/components/avatar'
import { Sidebar, SidebarBody, SidebarFooter, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import { ChevronRightIcon } from '@heroicons/react/16/solid'
import { Cog6ToothIcon, HomeIcon, MegaphoneIcon, Square2StackIcon, TicketIcon } from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
<SidebarFooter>
<SidebarSection>
<SidebarItem>
<Avatar src="/profile-photo.jpg" />
<SidebarLabel>Erica</SidebarLabel>
<ChevronRightIcon />
</SidebarItem>
</SidebarSection>
</SidebarFooter>
</Sidebar>
)
}
import { Avatar } from '@/components/avatar'
import { Sidebar, SidebarBody, SidebarFooter, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import { ChevronRightIcon } from '@heroicons/react/16/solid'
import { Cog6ToothIcon, HomeIcon, MegaphoneIcon, Square2StackIcon, TicketIcon } from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
<SidebarFooter>
<SidebarSection>
<SidebarItem>
<Avatar src="/profile-photo.jpg" />
<SidebarLabel>Erica</SidebarLabel>
<ChevronRightIcon />
</SidebarItem>
</SidebarSection>
</SidebarFooter>
</Sidebar>
)
}
With section headings
Use the SidebarHeading
component to add a heading to a section:
import { Sidebar, SidebarBody, SidebarHeading, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import {
Cog6ToothIcon,
HomeIcon,
MegaphoneIcon,
QuestionMarkCircleIcon,
SparklesIcon,
Square2StackIcon,
TicketIcon,
} from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
<SidebarSection>
<SidebarHeading>Resources</SidebarHeading>
<SidebarItem href="/resources">
<QuestionMarkCircleIcon />
<SidebarLabel>Support</SidebarLabel>
</SidebarItem>
<SidebarItem href="/changelog">
<SparklesIcon />
<SidebarLabel>Changelog</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
import { Sidebar, SidebarBody, SidebarHeading, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import {
Cog6ToothIcon,
HomeIcon,
MegaphoneIcon,
QuestionMarkCircleIcon,
SparklesIcon,
Square2StackIcon,
TicketIcon,
} from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
<SidebarSection>
<SidebarHeading>Resources</SidebarHeading>
<SidebarItem href="/resources">
<QuestionMarkCircleIcon />
<SidebarLabel>Support</SidebarLabel>
</SidebarItem>
<SidebarItem href="/changelog">
<SparklesIcon />
<SidebarLabel>Changelog</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
With space between sections
Use the SidebarSpacer
component to space out sections in a sidebar:
import { Sidebar, SidebarBody, SidebarItem, SidebarLabel, SidebarSection, SidebarSpacer } from '@/components/sidebar'
import {
ArrowRightStartOnRectangleIcon,
Cog6ToothIcon,
HomeIcon,
MegaphoneIcon,
Square2StackIcon,
TicketIcon,
} from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
<SidebarSpacer />
<SidebarSection>
<SidebarItem href="/logout">
<ArrowRightStartOnRectangleIcon />
<SidebarLabel>Sign out</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
import { Sidebar, SidebarBody, SidebarItem, SidebarLabel, SidebarSection, SidebarSpacer } from '@/components/sidebar'
import {
ArrowRightStartOnRectangleIcon,
Cog6ToothIcon,
HomeIcon,
MegaphoneIcon,
Square2StackIcon,
TicketIcon,
} from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
<SidebarSpacer />
<SidebarSection>
<SidebarItem href="/logout">
<ArrowRightStartOnRectangleIcon />
<SidebarLabel>Sign out</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
With divider
Use the SidebarDivider
component to add a dividing line between sections in a sidebar:
import { Sidebar, SidebarBody, SidebarDivider, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import {
Cog6ToothIcon,
HomeIcon,
MegaphoneIcon,
QuestionMarkCircleIcon,
SparklesIcon,
Square2StackIcon,
TicketIcon,
} from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
<SidebarDivider />
<SidebarSection>
<SidebarItem href="/support">
<QuestionMarkCircleIcon />
<SidebarLabel>Support</SidebarLabel>
</SidebarItem>
<SidebarItem href="/changelog">
<SparklesIcon />
<SidebarLabel>Changelog</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
import { Sidebar, SidebarBody, SidebarDivider, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import {
Cog6ToothIcon,
HomeIcon,
MegaphoneIcon,
QuestionMarkCircleIcon,
SparklesIcon,
Square2StackIcon,
TicketIcon,
} from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
<SidebarDivider />
<SidebarSection>
<SidebarItem href="/support">
<QuestionMarkCircleIcon />
<SidebarLabel>Support</SidebarLabel>
</SidebarItem>
<SidebarItem href="/changelog">
<SparklesIcon />
<SidebarLabel>Changelog</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
With dropdown
Use the Dropdown
component add a dropdown menu to a sidebar by rendering the DropdownButton
as a SidebarItem
:
import { Avatar } from '@/components/avatar'
import {
Dropdown,
DropdownButton,
DropdownDivider,
DropdownItem,
DropdownLabel,
DropdownMenu,
} from '@/components/dropdown'
import { Sidebar, SidebarBody, SidebarHeader, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import { ChevronDownIcon, Cog8ToothIcon, PlusIcon } from '@heroicons/react/16/solid'
import { Cog6ToothIcon, HomeIcon, MegaphoneIcon, Square2StackIcon, TicketIcon } from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarHeader>
<Dropdown>
<DropdownButton as={SidebarItem}>
<Avatar src="/tailwind-logo.svg" />
<SidebarLabel>Tailwind Labs</SidebarLabel>
<ChevronDownIcon />
</DropdownButton>
<DropdownMenu className="min-w-64" anchor="bottom start">
<DropdownItem href="/teams/1/settings">
<Cog8ToothIcon />
<DropdownLabel>Settings</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/teams/1">
<Avatar slot="icon" src="/tailwind-logo.svg" />
<DropdownLabel>Tailwind Labs</DropdownLabel>
</DropdownItem>
<DropdownItem href="/teams/2">
<Avatar slot="icon" initials="WC" className="bg-purple-500 text-white" />
<DropdownLabel>Workcation</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/teams/create">
<PlusIcon />
<DropdownLabel>New team…</DropdownLabel>
</DropdownItem>
</DropdownMenu>
</Dropdown>
</SidebarHeader>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
import { Avatar } from '@/components/avatar'
import {
Dropdown,
DropdownButton,
DropdownDivider,
DropdownItem,
DropdownLabel,
DropdownMenu,
} from '@/components/dropdown'
import { Sidebar, SidebarBody, SidebarHeader, SidebarItem, SidebarLabel, SidebarSection } from '@/components/sidebar'
import { ChevronDownIcon, Cog8ToothIcon, PlusIcon } from '@heroicons/react/16/solid'
import { Cog6ToothIcon, HomeIcon, MegaphoneIcon, Square2StackIcon, TicketIcon } from '@heroicons/react/20/solid'
function Example() {
return (
<Sidebar>
<SidebarHeader>
<Dropdown>
<DropdownButton as={SidebarItem}>
<Avatar src="/tailwind-logo.svg" />
<SidebarLabel>Tailwind Labs</SidebarLabel>
<ChevronDownIcon />
</DropdownButton>
<DropdownMenu className="min-w-64" anchor="bottom start">
<DropdownItem href="/teams/1/settings">
<Cog8ToothIcon />
<DropdownLabel>Settings</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/teams/1">
<Avatar slot="icon" src="/tailwind-logo.svg" />
<DropdownLabel>Tailwind Labs</DropdownLabel>
</DropdownItem>
<DropdownItem href="/teams/2">
<Avatar slot="icon" initials="WC" className="bg-purple-500 text-white" />
<DropdownLabel>Workcation</DropdownLabel>
</DropdownItem>
<DropdownDivider />
<DropdownItem href="/teams/create">
<PlusIcon />
<DropdownLabel>New team…</DropdownLabel>
</DropdownItem>
</DropdownMenu>
</Dropdown>
</SidebarHeader>
<SidebarBody>
<SidebarSection>
<SidebarItem href="/">
<HomeIcon />
<SidebarLabel>Home</SidebarLabel>
</SidebarItem>
<SidebarItem href="/events">
<Square2StackIcon />
<SidebarLabel>Events</SidebarLabel>
</SidebarItem>
<SidebarItem href="/orders">
<TicketIcon />
<SidebarLabel>Orders</SidebarLabel>
</SidebarItem>
<SidebarItem href="/broadcasts">
<MegaphoneIcon />
<SidebarLabel>Broadcasts</SidebarLabel>
</SidebarItem>
<SidebarItem href="/settings">
<Cog6ToothIcon />
<SidebarLabel>Settings</SidebarLabel>
</SidebarItem>
</SidebarSection>
</SidebarBody>
</Sidebar>
)
}
See the Dropdown
docs for more information on building dropdown menus.