Navigated to /docs/ui/components/slider

Slider

Range input primitive.

Preview

A live, theme-aware example rendered with the published component.

Loading preview…

Import

Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.

TSX
tsximport { Slider } from "@tavojs/ui/slider";

The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/slider.

When to use

Use it when

Use `Slider` for numeric range input

Choose something else when

Avoid Slider when wrapping controls without labels or accessible names.

Examples

These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.

Slider example

TSXCreate: src/components/examples/SliderExample1.tsx
tsximport { Slider } from "@tavojs/ui/slider";
import { Field } from "@tavojs/ui";

export function SliderExample1() {
  return (
    <>
      <Field id="volume" label="Volume"><Slider name="volume" min={0} max={100} defaultValue={72} /></Field>
    </>
  );
}

Common props and defaults

A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.

PropTypeDefaultDescription
classNamestring

Optional class hook applied to the public root element owned by the component.
minnumber

Configures min for this component.
maxnumber

Configures max for this component.
stepnumber

Configures step for this component.

Complete TypeScript API

Import from @tavojs/ui/slider. Published exports: Slider, SliderProps.

SliderProps

PropertyTypeRequiredDescription
childrenChild

No

Inherited children attribute accepted by Slider.

classNamestring

No

Optional class hook applied to the public root element owned by the component.

sxSx

No

Inherited sx attribute accepted by Slider.

idstring

No

Inherited id attribute accepted by Slider.

rolestring

No

Inherited role attribute accepted by Slider.

styleRecord<string, unknown>

No

Inherited style attribute accepted by Slider.

titlestring

No

Inherited title attribute accepted by Slider.

tabIndexnumber

No

Inherited tabIndex attribute accepted by Slider.

hiddenboolean

No

Inherited hidden attribute accepted by Slider.

disabledboolean

No

Inherited disabled attribute accepted by Slider.

onClickTavoEventHandler<MouseEvent>

No

Inherited onClick attribute accepted by Slider.

onChangeTavoEventHandler<Event>

No

Inherited onChange attribute accepted by Slider.

onInputTavoEventHandler<Event>

No

Inherited onInput attribute accepted by Slider.

onKeyDownTavoEventHandler<KeyboardEvent>

No

Inherited onKeyDown attribute accepted by Slider.

onFocusTavoEventHandler<FocusEvent>

No

Inherited onFocus attribute accepted by Slider.

onBlurTavoEventHandler<FocusEvent>

No

Inherited onBlur attribute accepted by Slider.

minnumber

No

Configures min for this component.

maxnumber

No

Configures max for this component.

stepnumber

No

Configures step for this component.

valuenumber

No

Inherited value attribute accepted by Slider.

State ownership and DOM target

ConcernContract
StateNo component state contract is exposed; the application owns the rendered content and surrounding behavior.
DOM targetNative input attributes target the owned form control; wrapper-specific props stay on the documented component root.

Anatomy and related components

This component exposes one public component root rather than a compound member API.

Limitations

Avoid Slider when wrapping controls without labels or accessible names.

Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.

Accessibility

Form components pass through native attributes and should be paired with visible labels or accessible names.

  • Use Field, FormLabel, FormControlLabel, or aria-label for labeling.

  • Preserve native input semantics whenever possible.

  • Expose validation with error text and aria-invalid where relevant.

Component status

ContractCurrent value
Maturitystable
Categoryforms
Component import@tavojs/ui/slider
Explicit CSS import@tavojs/ui/css/slider
PreviewInteractive preview available on this page