Toggle Sidebar B
AppearanceLight & dark mode D

Rubber Segment

Segmented control with a rubber thumb that stretches across the old and new slot on a tap, squashes on landing and can be dragged, flicked and pulled past its ends.

Default

Tap a slot, or grab the thumb and drag or flick it. Pulled past either end it stretches like rubber.

Dark previewReplay previewOpen in new tab

Customize

Items
Size
Track
Thumb
Text
Active Text
Radius10px
Inset3px
Stretch100
Squash3px
Speed1x
Glide75

API Reference

RubberSegment

PropTypeDefaultDescription
items(string | { value: string; label: string; icon?: string })[]-The slots, in order. A string is both value and label. An icon is an Iconify name.
valuestringundefinedControlled value, bound with v-model:value. A change from outside jumps the thumb without animation.
defaultValuestringundefinedInitial value when uncontrolled. The first item if omitted.
trackColorstring'#27272a'The well behind the slots.
thumbColorstring'#fafafa'The rubber thumb, and the focus ring.
textColorstring'#fafafa'Idle labels, drawn at 70%.
activeTextColorstring'#18181b'The label revealed inside the thumb.
size'sm' | 'md' | 'lg''md'Track height 28, 36 or 44 pixels. Font and padding follow.
radiusnumber10Track corner radius in pixels.
insetnumber3Gap between the thumb and the track edge. The thumb corner is radius minus inset.
equalSlotsbooleantrueEvery slot the same width. Off, slots hug their labels and the thumb changes width per slot.
stretchnumber100How far a tap dilates the thumb across old and new slot before it contracts. 0 is a plain slide.
squashnumber3Pixels the trailing edge lands past the slot edge before relaxing. 0 removes the squash.
speednumber1Scales every phase together. 0.25 is slow motion.
glidenumber75How far a flick carries the thumb before it snaps. 0 always lands on the nearest slot.
draggablebooleantrueLets the thumb be grabbed, dragged and flicked.
disabledbooleanfalseDims the control and ignores input.
ariaLabelstring'Segmented control'Accessible name of the radio group.
EventDescription
changeEmitted with the value and the index on a tap, on a drag release and on every arrow key.
update:valueEmitted alongside change, for v-model:value.
SlotDescription
itemScoped slot with item and index. Replaces the content of a slot, in the track and in the thumb copy.

Accessibility

Keyboard shortcuts and ARIA behavior.

Shortcut Description
Arrow Right + Arrow DownSelects the next slot.
Arrow Left + Arrow UpSelects the previous slot.
Home + EndSelects the first or the last slot.
  • Rendered as a radiogroup of radio buttons with a roving tabindex. The thumb copy of the labels is hidden from assistive technology.
  • With prefers-reduced-motion the thumb jumps and dragging does not stretch past the ends.