Segmented control
Segmented radio group whose selected slab stretches toward the new option on a spring. Form-associated; arrow keys move it.
Playground
Change a prop and the component updates. Props marked live animate to the new value; the others rebuild the element.
<HfSegmented options="Chat,Code,Ultracode" value="Code" label="Mode" name="mode" />
Installation
pnpm dlx shadcn@latest add @lumesec/hf-segmentedFirst timeRegister the @lumesec registry once, or install by URL
Adds @lumesec to your components.json:
pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.jsonOr skip the setup and install by URL:
npx shadcn@latest add https://elements.lumesec.ai/r/hf-segmented.jsonUsage
import { HfSegmented } from "@/components/lumesec/hf-segmented";
export function Example() {
return (
<HfSegmented name="mode" options="Chat,Code,Ultracode" value="Code" />
);
}Behaviour
The selected slab is liquid: it stretches toward the new option on a spring and settles with a glint.
API reference
Attributes
optionsReact propoptionsTypestringDefaultChat,Code,UltracodeComma-separated option labels; empty entries are skipped. Observed: a change rebuilds the buttons and keeps the selection when its label is still there.
valueReact propvalueTypestringSelected option; must match a label exactly. Falls back to the first option on connect. Observed and reflected; unknown values set later are ignored.
labelReact proplabelTypestringDefaultModeAccessible name of the radio group. Observed.
nameReact propnameTypestringForm field name.
disabledReact propdisabledTypebooleanDefaultfalsePresence attribute. Disables the options; a disabled ancestor <fieldset> does the same.
Events
Events bubble and cross the shadow boundary unless the description says otherwise.
changeReact proponChangeDetail{ value: string }Fires when the user selects a different option. value is the option label. Not fired for changes from code.
Properties
valueTypestringLabel of the selected option. Setting it writes the value attribute; no event fires.
options (read-only)Typestring[]Option labels parsed from the options attribute.
Keyboard
| Keys | Action |
|---|---|
| ArrowLeft / ArrowUp, ArrowRight / ArrowDown | Select and focus the previous or next option, wrapping at the ends. |
Accessibility
- The container has
role="radiogroup"witharia-labelfromlabel. - Each option is a native button with
role="radio"andaria-checked. - Roving tabindex: only the selected option is in the tab order.
- The slab is drawn on an
aria-hiddencanvas. - Submits the selected option label under
name. No validation. Form reset returns to the option selected on the first connect;disabledor a disabled fieldset disables the options. - Reduced motion: the slab jumps to the selected option without the spring or wobble, and its texture is drawn once instead of flowing.
Theming
The element reads your shadcn theme tokens through its shadow root, so light and dark follow your theme. The accent comes from --lumesec. See Theming.
This component reads --foreground, --lumesec, --muted and --muted-foreground.
To restyle only LumeSec elements, set the matching --ui-* overrides: --ui-accent, --ui-fg, --ui-muted and --ui-track.
Notes
- When the selected label contains
ultra(case-insensitive) the slab uses a faster, brighter pattern. - The element sizes to its options by default; when it is given a larger width, the options share it equally.
Related
Was this page helpful?