Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

Segmented control

Tabs, filter or nav links on one bordered track, with a sliding pill, a badge note on a segment, an underline variant and an overflow menu.

Installation

pnpm add @heyramzi/ui bits-ui

Usage

import { AnimatedTabs, SegmentedFilter } from "@heyramzi/ui/components/segmented";
<AnimatedTabs tabs={views} bind:value={tab} ariaLabel="View" />
<SegmentedFilter
  options={[
    { value: "all", label: "All" },
    { value: "open", label: "Open", count: 4 },
  ]}
  bind:value={filter}
  ariaLabel="Status"
/>

Keyboard and accessibility

Key Does
Arrow Right Arrow Left Moves to the next or previous segment. AnimatedTabs opens it, SegmentedFilter waits for Space or Enter.
Home End In AnimatedTabs, moves to the first or last segment.
Tab In SegmentedFilter, moves into the strip on the picked segment. The strip is one stop.
Space Enter In SegmentedFilter, picks the focused segment.
  • AnimatedTabs is a tablist with panels. SegmentedFilter is a named group of radio buttons, and the picked one reports checked. SegmentedNav is a nav of links, and the current one reports the page.
  • Past the max, the extra segments fold into a More menu. It's a separate Tab stop after the strip, and it takes the picker's keys: arrows, Home, End, Enter and a letter to jump.
  • A segment that shows only a mark or icon is named by its label.
  • With reduced motion on, the pill fades to the new segment. It doesn't slide.

API reference

AnimatedTabs

tabs required readonly TabDef<T>[]
value bindable T
onValueChange (value: T) => void
placement "toolbar" | "section" | "inline"
Default "toolbar"
block boolean
Default false
variant "pill" | "underline"
Default "pill"
ariaLabel string
toolbar import("svelte").Snippet
lead import("svelte").Snippet
listWrapperClass string
hideSingle boolean
Default false
max number
Default SEGMENT_MAX
moreLabel string
ref bindable HTMLElement | null
Default null
class string
children Snippet
...rest
Every prop of Tabs.Root from bits-ui except onValueChange, value
Prop Type Default
tabs required readonly TabDef<T>[]
value bindable T
onValueChange (value: T) => void
placement "toolbar" | "section" | "inline" "toolbar"
block boolean false
variant "pill" | "underline" "pill"
ariaLabel string
toolbar import("svelte").Snippet
lead import("svelte").Snippet
listWrapperClass string
hideSingle boolean false
max number SEGMENT_MAX
moreLabel string
ref bindable HTMLElement | null null
class string
children Snippet
...rest Every prop of Tabs.Root from bits-ui except onValueChange, value

SegmentedFilter

options required readonly TabDef<T>[]
value required bindable T
onValueChange (value: T) => void
counts Partial<Record<T, number>>
ariaLabel required string
block boolean
Default true
Fill the row rather than sit at its natural width. On for the list-page filter strip, off for a segment sitting in a toolbar beside others.
max number | "none"
Default SEGMENT_MAX
Objects the row may draw before its tail becomes a menu. See `collapse.ts`. `"none"` never folds.
moreLabel string
What the menu segment says. Translate at the call site.
iconOnly boolean
Default false
An option with an `image` or `icon` draws the mark alone; its label moves to `aria-label` and the title. For a cramped toolbar of well-known brand marks.
class string
Prop Type Default
options required readonly TabDef<T>[]
value required bindable T
onValueChange (value: T) => void
counts Partial<Record<T, number>>
ariaLabel required string
block

Fill the row rather than sit at its natural width. On for the list-page filter strip, off for a segment sitting in a toolbar beside others.

boolean true
max

Objects the row may draw before its tail becomes a menu. See `collapse.ts`. `"none"` never folds.

number | "none" SEGMENT_MAX
moreLabel

What the menu segment says. Translate at the call site.

string
iconOnly

An option with an `image` or `icon` draws the mark alone; its label moves to `aria-label` and the title. For a cramped toolbar of well-known brand marks.

boolean false
class string

SegmentedTrack

fill boolean
Default false
Fill the row rather than sit at its natural width.
variant "pill" | "underline"
Default "pill"
`pill`, a grey track with a white thumb that slides, or `underline`, a travelling rule.
class string
children required Snippet
after Snippet
A last segment that isn't an item: today the overflow trigger. It's inside the track but outside the ARIA container, so a `tablist` owns only tabs.
Prop Type Default
fill

Fill the row rather than sit at its natural width.

boolean false
variant

`pill`, a grey track with a white thumb that slides, or `underline`, a travelling rule.

"pill" | "underline" "pill"
class string
children required Snippet
after

A last segment that isn't an item: today the overflow trigger. It's inside the track but outside the ARIA container, so a `tablist` owns only tabs.

Snippet

SectionRuns

strip required SectionStrip
class string
The host row's own constraints: order, width, container queries.
Prop Type Default
strip required SectionStrip
class

The host row's own constraints: order, width, container queries.

string

SegmentedNav

items required readonly SegmentedNavItem[]
current required string
The href that is current. Compared after trailing slashes are dropped.
ariaLabel required string
block boolean
Default false
Fill the row rather than sit at its natural width.
class string
Prop Type Default
items required readonly SegmentedNavItem[]
current required

The href that is current. Compared after trailing slashes are dropped.

string
ariaLabel required string
block

Fill the row rather than sit at its natural width.

boolean false
class string