Forms

Slider

Single-thumb numeric range track. Optional tick dots and labels mark step increments, custom intervals, or preset positions. Pair with <SliderValue> when you need a numeric readout.

Preview
01 Installation

Install

Pull Slider from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { Slider } from "@brika/clay";
tsxGranular1 line
import { Slider } from "@brika/clay/components/slider";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxSlider.tsx11 lines
import { Slider, SliderValue } from '@brika/clay/components/slider';
import { useState } from 'react';
export default function SliderDefaultDemo() {
  const [value, setValue] = useState(50);
  return (
    <div className="flex w-full max-w-xs items-center gap-2">
      <Slider value={value} onChange={setValue} min={0} max={100} step={1} className="flex-1" />
      <SliderValue value={value} onChange={setValue} min={0} max={100} step={1} unit="%" />
    </div>
  );
}
03 Examples

Slider, every way

Custom Ticks

Step Dots

Step Interval

04 Accessibility

Accessibility

  • Built on a native <input type="range">, all keyboard and AT semantics are native.
  • Arrow keys adjust value by step; Home/End jump to min/max.
  • Always provide a visible label linked via htmlFor or wrapped <label>.
  • SliderValue pairing gives a numeric readout, include unit for percentage or currency.
05 Tokens 20 theme-overridable

Theme tokens

Every CSS variable Slider reads, with its default and the dotted path you'd write in a ThemeConfig JSON to override it. Set any of these in your theme to retune Slider without touching component code.

Slider tokens

20 tokens
ColorFill, border, and text colors.13
  • --slider-trackcolorvar(--muted)
    components.slider.track

    Unfilled portion of the track.

  • --slider-fillcolorvar(--primary)
    components.slider.fill

    Filled portion of the track (left of the thumb).

  • --slider-thumbcolorvar(--primary)
    components.slider.thumb

    Thumb fill color.

  • --slider-thumb-bordercolorvar(--background)
    components.slider.thumbBorder

    Thumb border (the halo separating thumb from track).

  • --slider-tickcolorvar(--foreground)
    components.slider.tick

    Inactive tick dot color (over the unfilled track). Used with reduced opacity.

  • --slider-tick-activecolorvar(--primary-foreground)
    components.slider.tickActive

    Active tick dot color (over the filled track). Used with reduced opacity.

  • --slider-labelcolorvar(--muted-foreground)
    components.slider.label

    Tick label text color.

  • --slider-label-activecolorvar(--foreground)
    components.slider.labelActive

    Tick label color when its value matches the current slider value.

  • --slider-value-containercolorvar(--input-container)
    components.slider.valueContainer

    Background color of the boxed numeric `<SliderValue>` readout/input. Defaults to the input-component fill so the readout matches sibling inputs.

  • --slider-value-bordercolorvar(--input-border)
    components.slider.valueBorder

    Border color of the `<SliderValue>` input box. Defaults to the input-component border.

  • --slider-value-labelcolorvar(--input-label)
    components.slider.valueLabel

    Numeric text color inside `<SliderValue>`. Defaults to the input-component label color.

  • --slider-value-ringcolorvar(--ring)
    components.slider.valueRing

    Border color of `<SliderValue>` when its inner input is focus-visible.

  • --slider-value-unitcolorvar(--muted-foreground)
    components.slider.valueUnit

    Color of the optional unit suffix rendered next to the value (e.g. "%", "px").

GeometrySizes, lengths, and corner radii.5
  • --slider-track-heightsize0.25rem
    components.slider.trackHeight

    Slider track thickness.

  • --slider-thumb-sizesize1rem
    components.slider.thumbSize

    Slider thumb diameter.

  • --slider-thumb-radiusradius9999px
    components.slider.thumbRadius

    Thumb corner radius. Lower for square thumbs.

  • --slider-tick-sizesize0.25rem
    components.slider.tickSize

    Tick dot diameter on the track.

  • --slider-radiusradius9999px
    components.slider.radius

    Track corner radius. Set lower for square / brutalist looks.

BorderBorder width and style.1
  • --slider-thumb-border-widthborder-width2px
    components.slider.thumbBorderWidth

    Thumb border width, the contrast halo between the thumb and the track.

ElevationDrop shadow and depth.1
  • --slider-thumb-shadowshadowvar(--shadow-raised)
    components.slider.thumbShadow

    Thumb drop shadow. Falls back to the global `--shadow-raised`.

Override in a theme

Authoring a theme is plain JSON. Drop overrides under components.slider, the names are camelCase versions of the variable suffix.

jsonmy-theme.json12 lines
{
  "id": "my-theme",
  "name": "My Theme",
  "description": "...",
  "accentSwatches": ["#000"],

  "components": {
    "slider": {
      "radius": "9999px"
    }
  }
}

Then apply with applyTheme(myTheme) (see the theming guide), scope it to a subtree with themeToCssVars(myTheme, mode), or consume any token directly in your own JSX with the matching Tailwind utility (e.g. bg-slider-…) — see the chips on each token row.

06 API reference

API reference

Props specific to Slider. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.

<Slider />

8 props
  • number
    Upper numeric bound.
  • number
    Lower numeric bound.
  • (next: number) => void
    Called with the next value as the user drags or types.
  • number
    Increment for keyboard arrows and value snapping.
  • number
    Current numeric value (controlled).
  • string
    Extra Tailwind classes appended to the slider wrapper.
  • SliderTickLabels
    Render labels below each tick. Pairs with ticks. See .
  • SliderTicks
    Render tick dots on the track. See .

<SliderValue />

9 props
  • number
    Upper numeric bound.
  • number
    Lower numeric bound.
  • (next: number) => void
    Called with the next value as the user drags or types.
  • number
    Increment for keyboard arrows and value snapping.
  • number
    Current numeric value (controlled).
  • string
    Extra Tailwind classes appended to the value-input wrapper.
  • number
    Round displayed numeric value to this many decimals.
  • string
    Suffix appended to the displayed value (e.g. "%", "px").
  • widthdefault 'w-10'
    string
    Tailwind width class for the numeric input. Defaults to w-10.