Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Web docs
Navigation

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
01

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.

AstroCode target · live preview uses Astro
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.
astro
---
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>
Edit SidebarItem in browser

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.

02

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.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add SidebarItem

API 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.

AttributeValuesDefaultDescription
labelstring | ReactNode / label slotrequiredVisible link text.
hrefstring-Destination. It is dropped when the item is disabled.
descriptionstring | ReactNode / description slot-Secondary line under the label.
iconReactNode / icon slot-Leading icon. It is hidden from assistive technology because the label names the link.
badgenumber | string / badge slot-Trailing count or short status. Screen readers hear it in parentheses after the label. Zero is shown; blank text is not.
currentbooleanfalseSets aria-current="page" and the selected style. Elements set it on the host and it is applied to the link child.
disabledbooleanfalseRemoves 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, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML 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.

cssScoped theme overrides
.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.

HookValuesDefaultContract
class, classNamestring""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


Web docsFull catalog