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; changes from code fire no events.
minReact propminTypenumberDefault0Lower bound. Observed.
maxReact propmaxTypenumberDefault100Upper bound. Observed.
stepReact propstepTypenumberDefault1Step size. Its decimal places also set the displayed precision. Values at or below 0 fall back to 1. Observed.
prefixReact propprefixTypestringText before the displayed value, for example $. Observed.
unitReact propunitTypestringText after the displayed value, for example ms. Observed.
labelReact proplabelTypestringVisible label; also names the slider through aria-labelledby. Observed.
nameReact propnameTypestringForm field name.
disabledReact propdisabledTypebooleanDefaultfalsePresence attribute. Disables the slider; a disabled ancestor <fieldset> does the same.
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. Not fired when value is set from code.
changeReact proponChangeDetail{ value: number }Fires on pointer release and after each key press that changed the value.
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 restores the value from the first connect;disabledor a disabled fieldset takes the slider out of the tab order. - 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
- All attributes are observed. New bounds or a new
stepre-clamp and re-snap the value without events and update the end labels under the track.
Related
Was this page helpful?