Slider

Component to select a value within a range.

The <Slider> is a form component that allows users to quickly select a value within a range. They should be used when the upper and lower bounds of the range are known and static.

For accessibility reasons you can use the left and right arrow keys on your keyboard to select a value.

Import

import { Slider } from '@marigold/components';

Appearance

Sorry! There are currently no variants and sizes available.

Props

PropertyTypeDefaultDescription
disabledbooleanfalseIf true, the slider is disabled.
valuenumber[]noneThe slider's value (controlled).
defaultValuenumber[]noneThe slider's default value (uncontrolled).
maxValuenumber100The slider's maximum value.
stepnumbernoneThe slider's step value.
formatOptionsIntl.NumberFormatOptions noneSet the format for the slider. E.g. percent
widthstring | numberfullSets the width of the field. You can see allowed tokens here: https://tailwindcss.com/docs/width
...-Yes you can use all regular attributes of input type = range!

Examples

Width

Here you can see a <Slider> with a smaller width than the default.

0

Disabled

You can also disable the <Slider> if you want user not to select a value.

0

Step

This example shows how to use the step property. The value is set in steps of 10.

0

Max value

If you want to use a other maxValue than 100. You can set the property and change it to the value you want.

0

Value (controlled)

This example shows how to build a controlled <Slider>. The value prop together with the onChange prop are used to update and set the current value. The default value in the example is set to "75", if you manually change the value it will be updated. If you want an uncontrolled <Slider> see the next example.

75

Default Value (uncontrolled)

If you just set the defaultValue property, your <Slider> will be uncontrolled. In this case you don't have an onChange event. If you want a controlled <Slider> see the example above.

25

Format Options

In this example you can see which format the <Slider> can have. You can use all NumberFormatOptions for that.

€0.00
0%