Slider
Form-associated range slider with a dithered fill and a lens for a thumb that magnifies the dots beneath it.
Playground
Change a prop and the component updates. Props marked live animate to the new value; the others rebuild the element.
<HfSlider
value={0.7}
min={0}
max={1}
step={0.05}
label="Temperature"
name="temp"
/>Installation
pnpm dlx shadcn@latest add @lumesec/hf-sliderFirst 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-slider.jsonUsage
import { HfSlider } from "@/components/lumesec/hf-slider";
export function Example() {
return (
<HfSlider name="temp" label="Temperature" min={0} max={1} step={0.05} value={0.7} />
);
}Behaviour
A dithered fill with a lens for a thumb: the dots under it are magnified, so you can see the exact position.
API reference
Attributes
valueReact propvalueTypenumberCurrent value, clamped to min–max and snapped to step. Defaults to min. Observed and reflected back with the snapped value.
minReact propminTypenumberDefault0Lower bound.
maxReact propmaxTypenumberDefault100Upper bound.
stepReact propstepTypenumberDefault1Step size. Its decimal places also set the displayed precision.
prefixReact propprefixTypestringText before the displayed value, for example $.
unitReact propunitTypestringText after the displayed value, for example ms.
labelReact proplabelTypestringVisible label; also names the slider through aria-labelledby.
nameReact propnameTypestringForm field name.
Events
Events bubble and cross the shadow boundary unless the description says otherwise.
inputReact proponInputDetail{ value: number }Fires on every value change from a drag or key press.
changeReact proponChangeDetail{ value: number }Fires on pointer release and on each key press.
Properties
valueTypenumberCurrent value. Setting it clamps, snaps and reflects to the attribute without firing events.
min (read-only)TypenumberParsed min.
max (read-only)TypenumberParsed max.
step (read-only)TypenumberParsed step.
frac (read-only)TypenumberPosition of the value in the range, 0 to 1.
Keyboard
| Keys | Action |
|---|---|
| ArrowRight / ArrowUp | Increase by one step. |
| ArrowLeft / ArrowDown | Decrease by one step. |
| PageUp / PageDown | Change by a tenth of the range. |
| Home / End | Jump to min or max. |
Accessibility
- The track has
role="slider"andtabindex="0"and is named by the label througharia-labelledby. - Sets
aria-valuenow,aria-valuemin,aria-valuemaxandaria-valuetext(formatted withprefixandunit) on every change. - Pressing on the track focuses it.
- Submits the current value as a string under
name. No validation; form reset does not change the value. - Reduced motion: the thumb jumps to the value without the spring and the value text swaps without rolling.
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 and --muted-foreground.
To restyle only LumeSec elements, set the matching --ui-* overrides: --ui-accent, --ui-fg, --ui-mono and --ui-muted.
Notes
min,maxandstepare not observed; the end labels under the track are set once on connect.
Related
Was this page helpful?