SidebarItem
Links a Sidebar destination with an icon, a two-line label, a count, and current or disabled states.
- Frameworks
- Astro · React · Elements · Dioxus
- Registry
lumen add SidebarItem- Interaction
- Native markup
See it and copy it
Framework example
Choose Astro, React, Elements, or Dioxus to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.
View SidebarItem code
Framework usage
Switch targets to compare the adapter code. This live preview runs the Astro example. Before copying an example, complete the matching framework setup; React, Elements, and Dioxus use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.---
import { Icon, Sidebar, SidebarItem } from '@santi020k/lumen-astro'
const items = [
{ badge: 12, current: true, description: 'Messages and mentions', href: '/docs', icon: 'inbox', label: 'Inbox' },
{ description: 'Active work', href: '/docs', icon: 'folder', label: 'Projects' },
{ href: '/docs', icon: 'settings', label: 'Settings' },
{ description: 'Ask an owner for access', disabled: true, href: '/docs', icon: 'credit-card', label: 'Billing' }
]
---
{/* On narrow screens, give the Sidebar collapse="sheet" and an id, and open it with a SidebarTrigger. */}
<Sidebar>
<nav aria-label="Workspace">
{items.map(({ icon, ...item }) => (
<SidebarItem {...item}>
<Icon slot="icon" name={icon} />
</SidebarItem>
))}
</nav>
</Sidebar>import { Icon, Sidebar, SidebarItem } from '@santi020k/lumen-react'
// On narrow screens, give the Sidebar collapse="sheet" and an id, and open it with a SidebarTrigger.
export const Example = () => (
<Sidebar>
<nav aria-label="Workspace">
<SidebarItem badge={12} current description="Messages and mentions" href="/inbox" icon={<Icon name="inbox" />} label="Inbox" />
<SidebarItem description="Active work" href="/projects" icon={<Icon name="folder" />} label="Projects" />
<SidebarItem href="/settings" icon={<Icon name="settings" />} label="Settings" />
<SidebarItem description="Ask an owner for access" disabled icon={<Icon name="credit-card" />} label="Billing" />
</nav>
</Sidebar>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-sidebar>
<nav aria-label="Workspace">
<lumen-sidebar-item current>
<a data-slot="sidebar-item-link" href="/inbox">
<span aria-hidden="true" data-slot="sidebar-item-icon"><lumen-icon name="inbox"></lumen-icon></span>
<span data-slot="sidebar-item-text">
<span data-slot="sidebar-item-label">Inbox</span>
<span data-slot="sidebar-item-description">Messages and mentions</span>
</span>
<span data-slot="sidebar-item-badge"><span class="ui-sr-only"> (</span>12<span class="ui-sr-only">)</span></span>
</a>
</lumen-sidebar-item>
<lumen-sidebar-item disabled>
<a data-slot="sidebar-item-link" href="/billing">
<span data-slot="sidebar-item-text"><span data-slot="sidebar-item-label">Billing</span></span>
</a>
</lumen-sidebar-item>
</nav>
</lumen-sidebar>use dioxus::prelude::*;
use lumen_dioxus::prelude::*;
#[component]
fn Example() -> Element {
rsx! {
SidebarItem { current: true, href: "/inbox", label: "Inbox", description: "All mail", badge: "12" }
SidebarItem { disabled: true, href: "/spam", label: "Spam" }
}
}Framework differences
Elements: Wrap one <a data-slot="sidebar-item-link"> in lumen-sidebar-item. The host has no box of its own; current and disabled on the host update the link.
Choose your target
Add this component
Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.
pnpm add @santi020k/lumen-astrolumen add SidebarItempnpm add @santi020k/lumen-reactlumen add SidebarItem --target reactpnpm add @santi020k/lumen-elementslumen add SidebarItem --target elementsAPI reference
Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.
| Attribute | Values | Default | Description |
|---|---|---|---|
| label | string | ReactNode / label slot | required | Visible link text. |
| href | string | - | Destination. It is dropped when the item is disabled. |
| description | string | ReactNode / description slot | - | Secondary line under the label. |
| icon | ReactNode / icon slot | - | Leading icon. It is hidden from assistive technology because the label names the link. |
| badge | number | string / badge slot | - | Trailing count or short status. Screen readers hear it in parentheses after the label. Zero is shown; blank text is not. |
| current | boolean | false | Sets aria-current="page" and the selected style. Elements set it on the host and it is applied to the link child. |
| disabled | boolean | false | Removes href and sets role="link" with aria-disabled="true", so the item cannot navigate or take focus. Elements restore the href when the attribute is removed. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML attributes | - | Forwards standard attributes to the root element unless the component consumes them. |
Customize SidebarItem
Start with semantic theme tokens and a class on the public component. Keep its accessible name, focus treatment, and interaction state intact.
.product-sidebar-item {
--surface: 0 0% 100%;
--ink: 220 20% 15%;
--line: 220 15% 82%;
}Apply product-sidebar-item through Astro's class, React's className, or the custom element's class. Verify foreground and background contrast in both schemes.
| Hook | Values | Default | Contract |
|---|---|---|---|
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
Use the documented hooks above and adapter types when targeting component states. Theme guide · Accessibility verification scope