Search...

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.

js
import { CDBSlider } from 'cdbreact';

Default Slider

js
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.

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"}} ... />

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.