Components / Inputs
Slider
Native range input, styled.
import { Slider } from "@stylhero/ui";
Example
Code
import { Slider } from "@stylhero/ui";
function SliderExample() {
return <Slider label="Budget" min={500} max={3000} step={50} defaultValue={1200} showValue={(v) => `$${v}`} />;
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
defaultValue |
number |
- | |
error |
ReactNode |
- | |
hint |
ReactNode |
- | Help text under the field. Replaced by error when set. |
label |
ReactNode |
- | |
max |
number |
100 |
|
min |
number |
0 |
|
onValueChange |
(value: number) => void |
- | |
showValue |
boolean | ((value: number) => ReactNode) |
- | Show the current value next to the label. Pass a function to format it. |
value |
number |
- |
Also takes every <input> attribute (id, style, data-*, aria-*, event handlers…), passed to that element. Takes a ref.
Keyboard
| Key | Does |
|---|---|
| Arrow keys | Change the value by one step |
| Home / End | Minimum / maximum |
| PageUp / PageDown | Bigger steps |
Accessibility
- A native
<input type="range">with its label. - The label, hint and error are linked to the control (
aria-describedby), anderrorsetsaria-invalid.
Generated from src/components/Slider.tsx. Something wrong or missing? Open an issue.