Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

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

PropTypeDefaultDescription
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

KeyDoes
Arrow keysChange the value by one step
Home / EndMinimum / maximum
PageUp / PageDownBigger steps

Accessibility

  • A native <input type="range"> with its label.
  • The label, hint and error are linked to the control (aria-describedby), and error sets aria-invalid.

Generated from src/components/Slider.tsx. Something wrong or missing? Open an issue.