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.
| Name | Type | Default | Description | Example |
|---|---|---|---|---|
| className | String | Adds custom classes | <CDBSlider className="myClass" ... /> | |
| value | Number or String | Slider's value - useful for additional data binding and edge use-cases | <CDBSlider value={49} ... /> | |
| tag | String | div | Changes default input tag | <CDBSlider tag="input" ... /> |
| disable | Boolean | false | Disables Slider component | <CDBSlider disabled .../> |
| min | Number | 0 | Sets the lowest Slider's value | <CDBSlider min={10} ... /> |
| max | Number | 100 | Sets the highest Slider's value | <CDBSlider max={70} ... /> |
| step | Number | 1 | Specifies the interval between valid values in a number-based input. | <CDBSlider step={0.1} ... /> |
| size | String | Changes size of slider component. Choose from lg and sm | <CDBSlider size="sm" ... /> | |
| variant | String | dark | Changes default slider color; available values: [blue, red, teal, dark-grey, dark, blue-grey, amber, purple] | <CDBSlider variant="red" ... /> |
| onChange | function | Returns slider value, on onChange event | <CDBSlider onChange={handleChange} ... /> | |
| onAfterChange | function | executes a function after Change event | <CDBSlider onAfterChange={handleAfterChange} ... /> | |
| tooltip | String | Displays the current value of the slider. Can choose from auto, on or off | <CDBSlider tooltip="on" ... /> | |
| tooltipPlacement | String | Selects where to place tooltip. Can choose from top or bottom | <CDBSlider tooltipPlacement="top" ... /> | |
| tooltipLabel | function | Sets the label of the tooltip | <CDBSlider tooltipLabel={yourFunction} ... /> | |
| tooltipStyle | Object | Customize the style of the tooltip | <CDBSlider tooltipStyle={{ color: "red"}} ... /> |