1.3.0 • Published 5 months ago
@illa-design/slider v1.3.0
Slider
It is a number inpuit component that input value by slide.
Installation
yarn add @illa-design/slider
Import component
import { Slider } from "@illa-dedign/slider"
API
Slider Basic Properties
Props | Desc | Type | Default |
---|---|---|---|
showTicks | Whether show ticks | boolean | - |
showInput | Whether show number input | boolean | - |
reverse | Whether reverse ticks | boolean | - |
marks | set ticks‘ mark | Record<number, ReactNode> | - |
vertical | Whether make silder vertical | boolean | - |
tooltipVisible | Whether always show tooltip | boolean | - |
tooltipPosition | Set the position of tooltip | "top" | "tl" | "tr" | "bottom" | "bl" | "br" | "left" | "lt" | "lb" | "right" | "rt" | "rb" | "top" |
disabled | Whether disable the component | boolean | - |
min | Set minimum value | number | 0 |
max | Set maxmum value | number | 100 |
step | Set step of every tick | number | 1 |
onlyMarkValue | whether only marked value can be selected | boolean | - |
defaultValue | Set defaultValue | number | number[] | - |
formatTooltip | Customize the tooltip | (value: number) => string | ReactNode | - |
Slider Events
Props | Desc | Type | Default |
---|---|---|---|
onAfterChange | Callback after value is changed | (val: number | number[]) => void | - |
onChange | Callback when value is changed | (val: number | number[]) => void | - |
Example
Basic usage
<Slider
value={value}
onChange={(val: number | number[]) => {
setValue(val as number)
}}
style={{ width: 400 }}
/>
Set step
<Slider
defaultValue={0}
onChange={(val: number | number[]) => {
setValue(val as number)
}}
step={2}
showTicks
style={{ width: 400 }}
/>
Set input range
const [value, setValue] = React.useState(0)
<Slider
onChange={(val: number | number[]) => {
setValue(val as number)
}}
min={0}
max={20}
step={2}
showTicks
style={{ width: 400 }}
/>
Set tick's mark
const [value, setValue] = React.useState(0)
<Slider
onChange={(val: number | number[]) => {
setValue(val as number)
}}
step={2}
marks={{
0: "0km",
5: "5km",
10: "10km",
15: "15km",
}}
style={{ width: 400 }}
/>
Show number input
const [value, setValue] = React.useState(0)
<Slider
showInput
onChange={(val: number | number[]) => {
setValue(val as number)
}}
step={1}
marks={{
0: "0km",
5: "5km",
10: "10km",
15: "15km",
}}
style={{ width: 400 }}
/>
1.2.0
5 months ago
1.3.0
5 months ago
1.1.0
8 months ago
1.0.26
11 months ago
1.0.29
10 months ago
1.0.28
10 months ago
1.0.27
10 months ago
1.0.30
9 months ago
1.0.22
1 year ago
1.0.21
1 year ago
1.0.20
1 year ago
1.0.25
12 months ago
1.0.24
12 months ago
1.0.23
1 year ago
1.0.19
1 year ago
1.0.9
1 year ago
1.0.8
1 year ago
1.0.7
1 year ago
1.0.6
2 years ago
1.0.11
1 year ago
1.0.10
1 year ago
1.0.13
1 year ago
1.0.12
1 year ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago
0.0.10
2 years ago
0.0.11
2 years ago
0.0.12
2 years ago
0.0.13
2 years ago
0.0.14
2 years ago
0.0.15
2 years ago
0.0.9
2 years ago
0.0.16
2 years ago
0.0.17
2 years ago
0.0.8
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago