Tabs
Panels of content, shown one at a time.
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 tabs registry item installs these files:
-
app/components/ui_component.rb -
app/components/ui/tabs_component.rb -
app/components/ui/tabs/list_component.rb -
app/components/ui/tabs/trigger_component.rb -
app/components/ui/tabs/content_component.rb -
app/helpers/ui/tabs_helper.rb -
app/javascript/controllers/ui_tabs_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
The Stimulus controller implements the WAI-ARIA tabs pattern: roving tabindex,
automatic activation with ←/→,
Home/End,
and the aria-controls/aria-labelledby wiring.
Or render the components directly:
Composition
Examples
Default
Two panels with cards; the ui-tabs controller switches between them.
Account
Change your profile details here.
Password
Change your sign-in password here.
Disabled trigger
disabled: true removes the trigger from the keyboard flow and from activation.
API reference
Every part accepts class /
class_name and
**attrs.
| Component | Argument | Default | Description |
|---|---|---|---|
Tabs |
default_value |
nil |
The tab open at first; with no value, the first enabled one is activated. |
Tabs::Trigger |
value: (required) |
— | The identifier tying a trigger to the panel with the same value. |
Tabs::Trigger |
disabled |
false |
Removes the trigger from activation and from the keyboard flow. |
Tabs::Content |
value: (required) |
— | The matching panel; renders hidden until activated. |