Components
Slider

Slider

The Slider component is used to allow users to select a value within a specified range by dragging a thumb along a track. It is commonly used to adjust numerical values like volume or brightness.

Props

The Slider component accepts the following props:

NameTypeDefaultDescription
minnumber0The minimum value of the slider.
maxnumber100The maximum value of the slider.
valuenumberThe current value of the slider.
stepnumber1The step size by which the slider value changes.
onChange(value: number) => voidA callback function called when the slider value changes.
disabledbooleanIf true, the slider is disabled and cannot be interacted with.

Try It

import { Slider } from '@kloktun/uikit'
import { useState } from 'react'

export default function SliderExample() {
    const [value, setValue] = useState(50);

    const handleChange = (newValue) => {
        setValue(newValue);
    };

    return (
        <div className="flex flex-col gap-4">
            Value: {value}
            <Slider min={0} max={100} value={value} onChange={handleChange} />
        </div>
    );
}