Slider

Slider

slider is an interactive component that lets the user swiftly slide through possible values spread on the desired range.

Its basic implementation is quite simple and does not require big blocks of code.

Examples of React Bootstrap slider use:

  • Video progress bar
  • Volume increase/decrease
  • Enthusiasm-o-meter

Examples

Slider example.

import React from "react";
import { CDBSlider, CDBContainer } from "cdbreact";
const Slider = () => {
return (
<CDBContainer>
<CDBSlider value={value} setValue={setValue} style={{ width: "100%" }} />
</CDBContainer>
);
};
export default Slider;

API

In this section you will find advanced information about the Slider component. You will find out which modules are required, what are the possibilities of configuring the component, and what events and methods you can use to work with it.

Contrast Slider Import Statement

You need to import the Contrast Slider component first before using it.

import { CDBSlider } from "cdbreact";

API Reference: Contrast Slider Properties

The table below shows the configuration options of the CDBSlider component.

NameTypeDefaultDescriptionExample
classNameStringAdds custom classes<CDBSlider className="myClass" ... />
valueNumber or StringSlider's value - useful for additional data binding and edge use-cases<CDBSlider value={49} ... />
tagStringdivChanges default input tag<CDBSlider tag="input" ... />
disableBooleanfalseDisables Slider component<CDBSlider disabled .../>
minNumber0Sets the lowest Slider's value<CDBSlider min={10} ... />
maxNumber100Sets the highest Slider's value<CDBSlider max={70} ... />
stepNumber1Specifies the interval between valid values in a number-based input.<CDBSlider step={0.1} ... />
sizeStringChanges size of slider component. Choose from lg and sm<CDBSlider size="sm" ... />
variantStringdarkChanges default slider color; available values: [blue, red, teal, dark-grey, dark, blue-grey, amber, purple]<CDBSlider variant="red" ... />
onChangefunctionReturns slider value, on onChange event<CDBSlider onChange={handleChange} ... />
onAfterChangefunctionexecutes a function after Change event<CDBSlider onAfterChange={handleAfterChange} ... />
tooltipStringDisplays the current value of the slider. Can choose from auto, on or off<CDBSlider tooltip="on" ... />
tooltipPlacementStringSelects where to place tooltip. Can choose from top or bottom<CDBSlider tooltipPlacement="top" ... />
tooltipLabelfunctionSets the label of the tooltip<CDBSlider tooltipLabel={yourFunction} ... />
tooltipStyleObjectCustomize the style of the tooltip<CDBSlider tooltipStyle={{ color: "red"}} ... />