Slider

A control for selecting a value from a range.

Installation

Import the component from the passport-ui package.

components/example.tsx
1
2
3
import { Slider } from "passport-ui";
import { Label } from "passport-ui";
import { useState } from "react";

Usage

Basic example showing how to use the component.

components/example.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function SliderExample() {
const [value, setValue] = useState([50]);
return (
<div className="w-sm">
<div className="meta-container">
<Label>Slider</Label>
<Slider
value={value}
onValueChange={setValue}
max={100}
step={1}
/>
<p>Current value: {value.join(", ")}</p>
</div>
</div>
);
}
{/* Range slider */}
function RangeSlider() {
const [range, setRange] = useState([20, 80]);
return (
<Slider
value={range}
onValueChange={setRange}
max={100}
step={1}
/>
);
}

Additional resources

Documentation and examples are available in Storybook.