Sidebar
A side column that turns into a drawer on narrow screens.
From its breakpoint up (md by default) a sidebar is a column, always open. Below it, it’s a
drawer built on ui-sdk’s Drawer, like Sheet: its SidebarTrigger opens it, focus moves into it,
the page behind is set aside, and Escape, a tap outside or a swipe closes it. The trigger only
shows where the sidebar is a drawer. A SidebarProvider connects them, one sidebar a side; give a
second one a wider breakpoint, like xl, so the space between keeps room. Workspace is built
from it.
Dependencies
What it's built from and what's built from it in Base, read from the imports in its source.
| Uses | ButtonprimitiveScroll AreaprimitiveSheetTextprimitive |
|---|---|
| Used by | Workspaceblock |
| Packages | @ui-sdk/core@0.1.0-beta.20@ui-sdk/react@0.1.0-beta.20lucide-react@1.73.0 |
Installation
Set the project up for Base once first, as Getting started shows. Then add it with the CLI, or by hand.
With the CLI
Manually
Install its packages:
Add the components it uses first, listed under Dependencies.
Then copy the source:
API reference
Generated from Base's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.
Sidebar
A column from its breakpoint up, and below it a drawer its SidebarTrigger opens.
- actionsours
Controls at the end of the title bar.
Type ReactNode
- breakpointours
Where it becomes a column: md, lg or xl. Give a second sidebar a wider one, so the space between keeps room.
Type SidebarBreakpoint · Default md
- side*ours
Type SidebarSide
- sizeours
Its width: 16, 18 or 20rem.
Type "sm" | "md" | "lg" · Default lg
- title*ours
The sidebar's name, in its title bar.
Type ReactNode
SidebarProvider
Connects sidebars to their triggers. Holds up to one sidebar a side.
Takes the props of a native div.
SidebarTrigger
Opens a sidebar's drawer. Shows only below the sidebar's breakpoint, where it's a drawer, and not at all with no sidebar on that side.
- side*ours
Type SidebarSide
- sizeours
Height and padding. The
iconsizes are square, for a button holding only an icon.Type NonNullable<"xs" | "sm" | "md" | "lg" | "icon-xs" | "icon-sm" | "icon" | "icon-lg">
- variantours
How much the button stands out.
destructiveis a tint, for actions that can't be undone.Type NonNullable<"primary" | "destructive" | "secondary" | "outline" | "ghost" | "link">
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: ButtonState) => string)
- debug
Logs every state change with its reason to the console, in development builds.
Type boolean
- disabled
Stops presses. The button is natively disabled, so it leaves the tab order and its form doesn't submit through it, unless
focusableWhenDisabledis set.Type boolean · Default false
- focusableWhenDisabled
Keeps a disabled button in the tab order with
aria-disabledinstead of the native attribute, so it can hold focus while it becomes disabled and host a tooltip that says why. Presses still do nothing.Type boolean · Default false
- pendingAnnouncement
What screen readers hear once the button has been pending for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing.
Type string · Default "Loading"
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<ButtonState>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: ButtonState) => CSSProperties)
- type
What a native button does in a form:
"submit"submits it and"reset"resets it. Ignored when the button renders as something else.Type "button" | "submit" | "reset" · Default "button"
SidebarBreakpoint
Where a sidebar turns from a drawer into a column: Tailwind's md, lg and xl.
Takes the props of a native div.