Sidebar
A composable, collapsible, responsive sidebar for application layouts.
See the sidebar in a complete layout
The sidebar-01 block shows collapsing, the Cmd/Ctrl+B shortcut, and the mobile drawer.
Installation
Shadwire follows shadcn/ui's open code model: the component's source is copied into your application and becomes yours. Install it with the CLI:
The sidebar registry item installs these files:
-
app/components/ui_component.rb -
app/components/ui/sidebar_component.rb -
app/components/ui/sidebar/provider_component.rb -
app/components/ui/sidebar/trigger_component.rb -
app/components/ui/sidebar/rail_component.rb -
app/components/ui/sidebar/inset_component.rb -
app/components/ui/sidebar/input_component.rb -
app/components/ui/sidebar/header_component.rb -
app/components/ui/sidebar/footer_component.rb -
app/components/ui/sidebar/separator_component.rb -
app/components/ui/sidebar/content_component.rb -
app/components/ui/sidebar/group_component.rb -
app/components/ui/sidebar/group_label_component.rb -
app/components/ui/sidebar/group_action_component.rb -
app/components/ui/sidebar/group_content_component.rb -
app/components/ui/sidebar/menu_component.rb -
app/components/ui/sidebar/menu_item_component.rb -
app/components/ui/sidebar/menu_button_component.rb -
app/components/ui/sidebar/menu_action_component.rb -
app/components/ui/sidebar/menu_badge_component.rb -
app/components/ui/sidebar/menu_skeleton_component.rb -
app/components/ui/sidebar/menu_sub_component.rb -
app/components/ui/sidebar/menu_sub_item_component.rb -
app/components/ui/sidebar/menu_sub_button_component.rb -
app/helpers/ui/sidebar_helper.rb -
app/javascript/controllers/ui_sidebar_controller.js -
vendor/shadwire/shadwire.css
This component uses Stimulus, so the application needs importmap-rails and stimulus-rails with automatic controller loading.
Haven't installed the CLI yet? gem install shadwire, then shadwire init.
Usage
Wrap the page in ui_sidebar_provider;
it hosts the controller and exposes the widths as CSS variables.
Or render the components directly:
Composition
Examples
API reference
| API | Element | Description |
|---|---|---|
ui_sidebar_provider | div | Hosts the ui-sidebar controller; accepts default_open: and cookie_name:. |
ui_sidebar | div | The panel. Accepts side: (:left/:right), variant: (:sidebar/:floating/:inset) and collapsible: (:offcanvas/:icon/:none). |
ui_sidebar_trigger | button | Toggles the sidebar (click or Cmd/Ctrl+B). |
ui_sidebar_rail | button | The strip along the inner edge that toggles collapsing. |
ui_sidebar_inset | main | The content area beside the sidebar. |
ui_sidebar_header / ui_sidebar_footer | div | The top and bottom regions. |
ui_sidebar_content | div | The scrollable region holding the groups. |
ui_sidebar_group / _group_label / _group_content | div | A labelled menu section. The label takes tag:. |
ui_sidebar_group_action | button | An action pinned to the group's label; tag:. |
ui_sidebar_menu / _menu_item | ul / li | The list of menu items. |
ui_sidebar_menu_button | button/a | is_active:, variant:, size:, tag: and tooltip: (visible in icon mode only). |
ui_sidebar_menu_action / _menu_badge | button / div | An action and a badge pinned to the right of the item. The action takes tag:, and show_on_hover: to show it only while the row is hovered or focused. |
ui_sidebar_menu_sub / _menu_sub_item / _menu_sub_button | ul / li / a | A nested submenu. The button takes is_active:, size: and tag:. |
ui_sidebar_menu_skeleton | div | A loading placeholder; show_icon:. |