Segmented Control
A pill of liquid glass you can tap or drag between options.
Installation#
$ pnpm dlx shadcn@latest add @liquikit/segmented-controlNeeds the @liquikit registry in your components.json. Set it up once.
Usage#
import { SegmentedControl } from "@/components/liquikit/segmented-control"<SegmentedControl
options={["Day", "Week", "Month"]}
defaultValue="Week"
aria-label="Range"
/>It is a radio group underneath, so the arrow keys move between options.
Examples#
Icons#
A label can be any React node. Give icon labels an aria-label.
API Reference#
SegmentedControl
| Prop | Type | Default |
|---|---|---|
theme | "light" | "dark"Light or dark glass. Falls back to the nearest | — |
lens | Partial<LensProfile>Overrides for the lens profile, such as | — |
liquid | numberHow far the glass squashes and stretches as it moves. | — |
options* | ReadonlyArray<string | Segment>The segments, as strings or | — |
value | stringThe current value, when you control it. | — |
defaultValue | stringThe value it starts with, when it manages its own state. | — |
onValueChange | (value: string, eventDetails?: RadioGroup.ChangeEventDetails) => voidCalled with the new value when the user changes it. | — |
height | numberHeight of the control, in pixels. | — |
Also takes every prop of Base UI's radio group, plus className and style.