Slider
React Bootstrap 5 Slider
The React Bootstrap 5 Slider is a component that allows users to choose a value from a set of options on a sliding bar. The React Bootstrap 5 Slider simplifies controlling the volume of sound on a video or the progress of a video you're watching extremely simpler.
Applications of a React Bootstrap 5 slider:
- Brightness
- Volume increase/decrease
- Video Progression.
Importing the React Bootstrap 5 Slider Component
Import CDBSlider
into your project to use the Contrast React Bootstrap 5 Slider component.
import { CDBSlider } from 'cdbreact';
Default Slider
import React from 'react';import { CDBSlider, CDBContainer } from 'cdbreact';
const Slider = () => { return ( <CDBContainer> <CDBSlider value={50} setValue={0} style={{ width: '100%' }} /> </CDBContainer> );};export default Slider;
API Reference: Contrast React Bootstrap 5 Slider Props
This section will elaborate on the props available with the React Bootstrap 5 Slider component. You'll learn what these props do, how to use them, and what their default values are.
Other CDBSlider
prop options are included in the table below.
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"}} ... /> |
Build modern projects using Bootstrap 5 and Contrast
Trying to create components and pages for a web app or website from
scratch while maintaining a modern User interface can be very tedious.
This is why we created Contrast, to help drastically reduce the amount of time we spend doing that.
so we can focus on building some other aspects of the project.
Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants.
Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for
building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.