2.5.0 • Published 5 months ago

@asphalt-react/slider v2.5.0

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
5 months ago

Slider

Slider allows users to select a value from a range by dragging the thumb along a track. You can set the min, max, and configure the steps.

npm npm version

Usage

Usually Slider appears inside forms, filters, or other input elements where a range selection is needed.

import { Slider } from "@asphalt-react/slider"

 <Slider value={10} />

Intents

Slider support 3 intents:

  • Brand (Default)
  • Neutral
  • Accent

Accessibility

  • Slider thumb is in the page tab sequence and has the keyboard interactions as described in Slider Pattern.
  • Slider has the ARIA "slider" role.
  • It has the "aria-valuenow" property set to a value representing the current value.
  • It has the "aria-valuemin" property set to a value representing the minimum allowed value.
  • It has the "aria-valuemax" property set to a decimal value representing the maximum allowed value.

Props

neutral

Applies neutral intent.

typerequireddefault
boolfalsefalse

brand

Applies brand intent.

typerequireddefault
boolfalsefalse

accent

Applies accent intent.

typerequireddefault
boolfalsefalse

stretch

Applies stretch styles.

typerequireddefault
boolfalsefalse

min

Minimum value of the slider. Must be less than max.

typerequireddefault
numberfalse0

max

Maximum value of the slider. Must be greater than min.

typerequireddefault
numberfalse100

value

Value of the slider. Must be between min and max.

typerequireddefault
numbertrueN/A

step

Step increment of the slider. Must be greater than 0 or any. If the value is not a multiple of step, it will be rounded to the nearest valid value. If set to a number, the slider will move in fixed increments. If set to any, the slider allows any decimal or whole number within the range.

typerequireddefault
unionfalse1

onChange

Callback function for slider value changes.

onChange = (value, { event }) => {}
typerequireddefault
funcfalseN/A

onError

Callback function for slider value errors.

onError = (error) => {}
typerequireddefault
funcfalseN/A

disabled

Disables the slider.

typerequireddefault
boolfalsefalse

markers

Array of markers to display below the slider. Each mark should have a value and label property.

markers = [{ value: 0, label: "0", value: 100, label: "100"}]
typerequireddefault
arrayOffalsenull