SidebarTrigger
Opens a collapsed Sidebar as an off-canvas sheet on narrow screens and closes it from inside.
- Frameworks
- Astro · React · Elements · Dioxus
- Registry
lumen add SidebarTrigger- 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 SidebarTrigger 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 { AppHeader, Icon, Sidebar, SidebarItem, SidebarTrigger, Stack, Typography } from '@santi020k/lumen-astro'
const items = [
{ current: true, href: '/docs', icon: 'inbox', label: 'Inbox' },
{ href: '/docs', icon: 'folder', label: 'Projects' },
{ href: '/docs', icon: 'settings', label: 'Settings' }
]
---
<Stack gap="related">
<AppHeader>
<SidebarTrigger slot="leading" target="sidebar-trigger-example-nav" />
<span>Inbox</span>
</AppHeader>
<Stack direction="horizontal" gap="related">
<Sidebar aria-label="App" collapse="sheet" id="sidebar-trigger-example-nav">
<SidebarTrigger action="close" target="sidebar-trigger-example-nav" />
<nav aria-label="Workspace">
{items.map(({ icon, ...item }) => (
<SidebarItem {...item}>
<Icon slot="icon" name={icon} />
</SidebarItem>
))}
</nav>
</Sidebar>
<Typography>
<p>Below 48rem, the menu button opens the sidebar as a sheet. From 48rem, it stays beside the content.</p>
</Typography>
</Stack>
</Stack>import { AppHeader, Icon, Sidebar, SidebarItem, SidebarTrigger, Stack, Typography } from '@santi020k/lumen-react'
// Below 48rem the Sidebar is an off-canvas sheet; from 48rem it stays in the page flow and both triggers hide.
export const Example = () => (
<Stack gap="related">
<AppHeader leading={<SidebarTrigger target="app-nav" />}>
<span>Inbox</span>
</AppHeader>
<Stack direction="horizontal" gap="related">
<Sidebar aria-label="App" collapse="sheet" id="app-nav">
<SidebarTrigger action="close" target="app-nav" />
<nav aria-label="Workspace">
<SidebarItem current href="/inbox" icon={<Icon name="inbox" />} label="Inbox" />
<SidebarItem href="/projects" icon={<Icon name="folder" />} label="Projects" />
<SidebarItem href="/settings" icon={<Icon name="settings" />} label="Settings" />
</nav>
</Sidebar>
<Typography>
<p>Below 48rem, the menu button opens the sidebar as a sheet. From 48rem, it stays beside the content.</p>
</Typography>
</Stack>
</Stack>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-app-header>
<div data-slot="app-header-leading">
<lumen-sidebar-trigger target="app-nav"></lumen-sidebar-trigger>
</div>
<span>Inbox</span>
</lumen-app-header>
<lumen-sidebar collapse="sheet" id="app-nav">
<lumen-sidebar-trigger target="app-nav" action="close"></lumen-sidebar-trigger>
<nav aria-label="Workspace">
<lumen-sidebar-item current>
<a data-slot="sidebar-item-link" href="/inbox">
<span data-slot="sidebar-item-text"><span data-slot="sidebar-item-label">Inbox</span></span>
</a>
</lumen-sidebar-item>
<lumen-sidebar-item>
<a data-slot="sidebar-item-link" href="/projects">
<span data-slot="sidebar-item-text"><span data-slot="sidebar-item-label">Projects</span></span>
</a>
</lumen-sidebar-item>
</nav>
</lumen-sidebar>use dioxus::prelude::*;
use lumen_dioxus::prelude::*;
#[component]
fn Example() -> Element {
rsx! {
AppHeader {
leading: rsx! { SidebarTrigger { target: "app-nav" } },
span { "Inbox" }
}
Sidebar { aria_label: "App", collapse: SidebarCollapse::Sheet, id: "app-nav",
SidebarTrigger { action: SidebarTriggerAction::Close, target: "app-nav" }
nav { aria_label: "Workspace",
SidebarItem { current: true, href: "/inbox", label: "Inbox" }
SidebarItem { href: "/projects", label: "Projects" }
}
}
}
}Framework differences
React: Pass the trigger to AppHeader through its leading prop. A Sidebar with collapse="sheet" runs its own sheet behavior, so it needs no runtime mount.
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 SidebarTriggerpnpm add @santi020k/lumen-reactlumen add SidebarTrigger --target reactpnpm add @santi020k/lumen-elementslumen add SidebarTrigger --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 |
|---|---|---|---|
| target | string | required | The id of a Sidebar with collapse="sheet". The trigger points its native popover target and aria-controls at it. |
| action | "toggle" | "close" | "toggle" | toggle opens and closes the sidebar from outside it, usually in the AppHeader leading slot. close hides it from inside. |
| label | string | "Menu" or "Close menu" | Accessible name of the default icon. It is ignored when the trigger has its own content. |
| children / default slot | Astro slot | ReactNode | child nodes | menu icon | Replaces the icon and its hidden label. The trigger then uses the default Button size instead of the icon size. |
| 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 SidebarTrigger
Start with semantic theme tokens and a class on the public component. Keep its accessible name, focus treatment, and interaction state intact.
.product-sidebar-trigger {
--surface: 0 0% 100%;
--ink: 220 20% 15%;
--line: 220 15% 82%;
}Apply product-sidebar-trigger 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
Keyboard interactions
Keyboard behavior provided by native HTML controls.
| Key | Action |
|---|---|
| Enter, Space on the trigger | Open or close the collapsed sidebar below 48rem. |
| Escape in the sidebar | Close the sidebar and return focus to the trigger. |
| Enter on a sidebar link | Follow the link and close the sidebar. |
| Tab out of the sidebar | Close the sidebar once focus leaves it. |