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. Read once on first connect to build the buttons.
valueReact propvalueTypestringInitially selected option; must match a label exactly. Falls back to the first option. Read once on first connect.
labelReact proplabelTypestringDefaultModeAccessible name of the radio group.
nameReact propnameTypestringForm field name.
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.
Properties
value (read-only)TypestringLabel of the selected option. There is no setter.
options (read-only)Typestring[]Option labels parsed from the options attribute.
Keyboard
| Keys | Action |
|---|---|
| ArrowLeft / ArrowRight | 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.
- Submits the selected option label under
name. No validation; form reset does not change the selection. - 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
- Attributes are not observed. Changing
optionsorvalueafter the element connects has no effect. - 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?