Tabs
Panels that share one space, switched by a row of tab buttons.
Installation
Tip
Usage
src/app/app.ts
- A trigger and a panel belong together when their
valuematches. - Set a starting
value. With the default'', no tab is active and every panel is hidden. - Triggers wrap their content in
<text>, so pass plain text. - A label stays on one line, and one too long for its tab ends with "…".
- The tab bar hugs its triggers instead of filling the width, up to the width it's given.
Segmented control
Switch between closely related views with the platform's segmented control:
- A thumb slides to the tab you tap, or follows your finger when you drag it, and the panel switches where you let go.
- On iOS 26 the thumb lifts into Liquid Glass while it moves, as UIKit's segmented control does. Before iOS 26 it's the control of iOS 13 to 18, and on Android Material 3 Expressive's connected button group. See Toggle for what each platform draws.
- The phone ticks when the selection changes, with
LynxHaptics, on a tap and as a dragged thumb crosses onto each tab. - It fills the width it's given, and the tabs share it equally. As in UIKit, a label gets nearly its whole tab, and one that still doesn't fit ends with "…".
class="flex-[2]"on a trigger makes it wider.
Apple's guidelines suggest a segmented control for views that belong together, and a tab bar for separate sections of an app. Keep it to about five tabs on a phone.
Without a signal
A plain value sets the starting tab. changed emits the value of each tab the user taps.
Panels keep their state
Every panel stays rendered, and inactive ones are hidden rather than removed. So components inside a panel keep their state when the user switches away and back.
When the active tab changes, the new panel slides in from the side of the tab that was tapped.
API
UiTabs
UiTabsTrigger
No outputs.
UiTabsContent
No outputs.
UiTabsList
No outputs. The file also exports the TabsListVariant type.
Accessibility
- The list is a tab bar to VoiceOver, which reads each trigger as a tab and the selected one as selected.
- Reduce Motion: panels appear without sliding in, and the segmented control's thumb jumps instead of sliding or lifting into glass.
