Slider

An input where the user selects a value from within a given range.


Usage

  • Slider component takes in defaultValue, max, step props.
  • Note that both value prop and defaultValue prop take in value as array of single number
  • You can also pass value prop in conjunction with onValueChange prop to make use of value generated by Slider.
  • This can be accomplished using useState and useEffect

Interface for SliderProps

interface SliderProps {
  defaultValue?: number[];
  max: number;
  step?: number;
  value?: number[];
  onValueChange?: (value: number[]) => void;
}

Example of using value generated by Slider

import { Slider } from ".dubsui";
import { useState, useEffect } from "react";
 
const Primary = () => {
  const [value, setValue] = useState([33]); //value is 33 but passed as array
 
  useEffect(() => {
    console.log(value);
  }, [value]);
 
  return (
    <Slider
      value={value}
      onValueChange={setValue}
      //Default value is 33 but passed as array
      defaultValue={[33]}
      max={100}
      step={1}
    />
  );
};

    Theme

    Presets

    Background

    Custom:

    Primary

    Custom:

    Secondary

    Custom:

    Border

    Custom:

    Mode

    Light
    Dark