14.2.2 • Published 16 days ago

@rmwc/slider v14.2.2

Weekly downloads
3,346
License
MIT
Repository
github
Last release
16 days ago

Sliders

Sliders let users select from a range of values by moving the slider thumb.

Sliders can be both uncontrolled and controlled. When creating a controlled Slider, you should be listening to the onInput event and use evt.detail.value to set your new value.

Sliders will automatically layout themselves on window resize. If you need to manually trigger a layout because the sliders container size changed, the simplest way is to trigger a resize event window.dispatchEvent(new Event('resize'));.

Known Issue material-components-web uses pointer events internally. If you are using something below React 16.4, you will see unknown attribute errors, however the slider should still work.

<Slider
  onInput={(evt) => console.log(evt)}
  onChange={(evt) => console.log(evt)}
/>
function Example() {
  const [value, setValue] = React.useState(50);
  // onInput is required and will fire continuously.
  // onChange is optional and fires at the end of the interaction
  return (
    <Slider
      value={value}
      onChange={(evt) => setValue(evt.detail.value)}
      onInput={(evt) => setValue(evt.detail.value)}
      discrete
      step={10}
    />
  );
}
<Slider discrete min={0} max={200} step={10} />
<Slider discrete displayMarkers step={10} />
function Example() {
  const [value, setValue] = React.useState(80);
  const [startValue, setStartValue] = React.useState(20);
  return (
    <Slider
      range
      discrete
      valueStart={startValue}
      value={value}
      onChange={(evt) => setValue(evt.detail.value)}
      onChangeValueStart={(evt) => setStartValue(evt.detail.value)}
    ></Slider>
  );
}

Slider

A Slider component.

Props

NameTypeDescription
disabledbooleanDisables the control.
discretebooleanDisplays the exact value of the Slider on the knob.
displayMarkersbooleanDisplays the individual step markers on the Slider track.
foundationRefRef<MDCSliderFoundation<>>Advanced: A reference to the MDCFoundation.
maxstring \| numberThe maximum value of the Slider.
minstring \| numberThe minimum value of the Slider.
minRangestring \| numberThe minimum gap between two thumbs for range sliders.
onChange(evt: SliderOnChangeEventT) => voidA callback that fires when the Slider stops sliding which takes an event with event.detail.value set to the Slider's value. evt.detail = { value: number;}
onChangeValueStart(evt: SliderOnChangeEventT) => voidA callback that fires when the Slider stops sliding which takes an event with event.detail.value set to the Slider's valueStart. evt.detail = { value: number;}
onInput(evt: SliderOnInputEventT) => voidA callback that fires continuously while the Slider is sliding that takes an event with event.detail.value set to the Slider's value. evt.detail = { value: number;}
onInputValueStart(evt: SliderOnInputEventT) => voidA callback that fires continuously while the Slider is sliding that takes an event with event.detail.value set to the Slider's valueStart. evt.detail = { value: number;}
rangebooleanMakes the slider a range slider.
stepstring \| numberA step to quantize values by.
valuestring \| numberThe value of the Slider. When Slider is of type range, value becomes the end value.
valueStartnumberThe start value of the Slider range.
14.2.2

16 days ago

14.2.0

23 days ago

14.2.1

23 days ago

14.1.5

24 days ago

14.1.4

1 month ago

14.1.3

2 months ago

14.1.2

2 months ago

14.1.1

2 months ago

14.1.0

2 months ago

14.0.12

2 months ago

14.0.11

3 months ago

14.0.10

3 months ago

14.0.9

3 months ago

14.0.8

3 months ago

14.0.7

4 months ago

14.0.6

4 months ago

14.0.5

4 months ago

14.0.4

5 months ago

14.0.1-alpha.0

8 months ago

14.0.2-alpha.3

7 months ago

14.0.2-alpha.0

8 months ago

14.0.2-alpha.1

7 months ago

14.0.2-alpha.6

6 months ago

14.0.2-alpha.7

6 months ago

14.0.2-alpha.4

7 months ago

14.0.2-alpha.5

6 months ago

14.0.0

6 months ago

14.0.1

5 months ago

14.0.0-alpha.0

9 months ago

14.0.2

5 months ago

14.0.3

5 months ago

8.0.8

11 months ago

8.0.7

1 year ago

8.0.6

1 year ago

8.0.5

1 year ago

8.0.4

1 year ago

8.0.3

2 years ago

8.0.2

2 years ago

8.0.1

2 years ago

8.0.0

2 years ago

7.0.3

2 years ago

7.0.2

2 years ago

7.0.1

2 years ago

7.0.0

2 years ago

6.1.4

4 years ago

6.0.14

4 years ago

6.0.13

4 years ago

6.0.12

4 years ago

6.0.11

4 years ago

6.0.10

4 years ago

6.0.9

4 years ago

6.0.5

4 years ago

6.0.4

4 years ago

6.0.3

4 years ago

6.0.1

4 years ago

6.0.0

4 years ago

6.0.2

4 years ago

6.0.0-rc.1

4 years ago

6.0.0-rc.4

4 years ago

6.0.0-rc.3

4 years ago

6.0.0-rc.2

4 years ago

6.0.0-rc.0

4 years ago

6.0.0-alpha.16

4 years ago

6.0.0-alpha.14

4 years ago

6.0.0-alpha.15

4 years ago

6.0.0-alpha.13

4 years ago

6.0.0-alpha.12

4 years ago

6.0.0-alpha.11

4 years ago

6.0.0-alpha.7

4 years ago

5.7.2

4 years ago

6.0.0-alpha.4

4 years ago

6.0.0-alpha.5

4 years ago

6.0.0-alpha.6

4 years ago

6.0.0-alpha.3

4 years ago

6.0.0-alpha.1

4 years ago

5.7.0

5 years ago

5.6.0

5 years ago

5.5.2

5 years ago

5.5.1

5 years ago

5.5.0

5 years ago

5.4.3

5 years ago

5.4.2

5 years ago

5.4.1

5 years ago

5.4.0

5 years ago

5.3.1

5 years ago

5.3.0

5 years ago

5.2.2

5 years ago

5.2.1

5 years ago

5.2.0

5 years ago

5.2.0-alpha.0

5 years ago

5.1.8

5 years ago

5.1.7

5 years ago

5.1.6

5 years ago

5.1.5

5 years ago

5.1.4

5 years ago

5.1.3

5 years ago

5.1.2

5 years ago

5.1.1

5 years ago

5.1.0

5 years ago

5.0.30-rc.0

5 years ago

5.0.29-rc.0

5 years ago

5.0.28-rc.0

5 years ago

5.0.27-rc.0

5 years ago

5.0.26-rc.0

5 years ago

5.0.25-rc.0

5 years ago

5.0.24-rc.0

5 years ago

5.0.23-rc.0

5 years ago

5.0.23-alpha.0

5 years ago

5.0.22-alpha.0

5 years ago

5.0.21-alpha.0

5 years ago

5.0.20-alpha.0

5 years ago

5.0.19-alpha.0

5 years ago

5.0.18-alpha.0

5 years ago

5.0.17-alpha.0

5 years ago

5.0.16-alpha.0

5 years ago

5.0.15-alpha.0

5 years ago

5.0.14-alpha.0

5 years ago

5.0.13-alpha.0

5 years ago

5.0.12-alpha.0

5 years ago

5.0.8-alpha.0

5 years ago

5.0.7-alpha.0

5 years ago

5.0.6-alpha.0

5 years ago

5.0.5-alpha.0

5 years ago

5.0.4-alpha.0

5 years ago

5.0.3-alpha.0

5 years ago

5.0.2-alpha.0

5 years ago

5.0.1-alpha.0

5 years ago

5.0.0-alpha.0

5 years ago

4.0.6

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.0.11

5 years ago

3.0.10

5 years ago

3.0.9

6 years ago

3.0.8

6 years ago

3.0.7

6 years ago

3.0.6

6 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.0

6 years ago

2.2.0

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

2.0.0-alpha.7

6 years ago

2.0.0-alpha.6

6 years ago

2.0.0-alpha.5

6 years ago

2.0.0-alpha.4

6 years ago

2.0.0-alpha.3

6 years ago

2.0.0-alpha.2

6 years ago

2.0.0-alpha.1

6 years ago

2.0.0-alpha.0

6 years ago

1.10.1-alpha.0

6 years ago

1.10.0-alpha.0

6 years ago