Range Slider Ready
Range Slider lets user specify a numeric value using a slider which must be no less than a given value, and no more than another given value.
Examples #
Properties #
Property | Attribute | Description | Type | Default |
---|---|---|---|---|
accessibleActiveDescendant | accessible-active-descendant | Indicates the id of a related component’s visually focused element. | string | undefined |
accessibleControls | accessible-controls | Use this prop to add an aria-controls attribute. Use the attribute to indicate the id of a component controlled by this component. | string | undefined |
accessibleDescribedBy | accessible-described-by | Indicates the id of a component that describes the input. | string | undefined |
accessibleOwns | accessible-owns | Indicates the id of a component owned by the input. | string | undefined |
debounce | debounce | Set the amount of time, in milliseconds, to wait to trigger the duetChange event after each keystroke. | number | 0 |
disabled | disabled | Makes the input component disabled. This prevents users from being able to interact with the input, and conveys its inactive state to assistive technologies. | boolean | false |
expand | expand | Expands the input to fill 100% of the container width. | boolean | false |
identifier | identifier | Adds a unique identifier for the input. | string | undefined |
label | label | Label for the range slider. | string | "label" |
labelColor | label-color | Color of the label. | string | undefined |
labelHidden | label-hidden | Visually hide the label, but still show it to screen readers. | boolean | false |
labelWeight | label-weight | Font weight of the label. | "normal" | "semi-bold" | undefined |
locale | locale | Locale used to format the entered value. | "en-GB" | "en-US" | "fi-FI" | "sv-SE" | "fi-FI" |
margin | margin | Controls the margin of the component. | "auto" | "none" | "auto" |
max | max | Maximum value. | number | 100 |
min | min | Minimum value. | number | 0 |
name | name | Name of the input. | string | undefined |
required | required | Set whether the input is required or not. Please note that this is necessary for accessible inputs when the user is required to fill them. When using this property you need to also set “novalidate” attribute to your form element to prevent browser from displaying its own validation errors. | boolean | false |
step | step | Step amount. | number | 1 |
theme | theme | Theme of the input. | "" | "default" | "turva" | "" |
unit | unit | Unit for the range slider. | string | "" |
value | value | Value of the input. | number | 0 |
Events #
Event | Description | Type |
---|---|---|
duetChange | Emitted when the value has changed. | CustomEvent<{ originalEvent?: Event; component: "duet-range-slider"; value: number; }> |
duetInput | Emitted when a keyboard input ocurred. | CustomEvent<{ originalEvent?: Event; component: "duet-range-slider"; value: number; }> |
Methods #
setFocus(options?: FocusOptions) => Promise<void>
#
Sets focus on the specified duet-range-slider
. Use this method instead of the global
input.focus()
.
Parameters #
Name | Type | Description |
---|---|---|
options | FocusOptions |
Returns #
Type: Promise<void>
Usage #
This section includes guidelines for designers and developers about the usage of this component in different contexts.
When to use #
- To let user specify a numeric value using a slider which must be no less than a given value, and no more than another given value.
- When the accuracy of the numeric value entered isn’t important.
When not to use #
- When the accuracy of the numeric value entered is important. Consider using number input instead.
- For entering arbitrary numeric values. Use input component instead.
Accessibility #
This component has been validated to meet the WCAG 2.1 AA accessibility guidelines. You can find additional information regarding accessibility of this component below.
- Number Input component uses a basic HTML
<input type="range">
element behind the scenes and offers similar functionality and API for its users. - Never use range slider when the entered numeric value needs to be exact as using a slider based control can be hard for certain users.
label
property is always required for an accessible input control.labelHidden
property hides the above label visually, but still keeps it accessible for assistive technologies.disabled
property makes the range slider disabled. This prevents users from being able to interact with the range slider, and conveys its inactive state to assistive technologies.accessibleActiveDescendant
property can be used to indicate the id of a related component’s visually focused element.accessibleControls
property can be used to add an aria-controls attribute. Use the attribute to indicate the id of a component controlled by this component.accessibleOwns
property can be used to indicate the id of a component owned by the range slider.accessibleDescribedBy
property can be used to indicate the id of a component which contains descriptive/help text related to the range slider.
Integration
For integration, event and theming guidelines, please see Using Components. This documentation explains how to implement and use Duet’s components across different technologies like Angular, React or Vanilla JavaScript.
Tutorials
Follow these practical tutorials to learn how to build simple page layouts using Duet’s CSS Framework, Web Components and other features:
Building Layouts
TutorialsUsing CLI Tools
TutorialsCreating Custom Patterns
TutorialsServer Side Rendering
TutorialsSharing Prototypes
TutorialsUsage With Markdown
Troubleshooting
If you experience any issues while using a component, please head over to the Support page for more guidelines and help.