Ranges allow the user to select a single value within a given range using a slider.
Use the label attribute to give the range an accessible label. For labels that contain HTML, use the label slot instead.
Add descriptive help text to a range with the help-text attribute. For help texts that contain HTML, use the help-text slot instead.
Use the min and max attributes to set the range’s minimum and maximum values, respectively. The step attribute determines the value’s interval when increasing and decreasing.
Use the disabled attribute to disable a slider.
By default, the tooltip is shown on top. Set tooltip to bottom to show it below the slider.
To disable the tooltip, set tooltip to none.
You can customize the initial offset of the active track using the —track-active-offset custom property.
You can change the tooltip’s content by setting the tooltipFormatter property to a function that accepts the range’s value as an argument.
import '@ods/components/web.range';Note: You only need to import a web component once in your code, as it registers itself globally when defined, allowing you to use it anywhere within your application without needing to re-import it each time you want to use the component.
This component is still in development and cannot be imported at this time.
| Name | Description |
|---|---|
| label | The range's label. Alternatively, you can use the `label` attribute. |
| help-text | Text that describes how to use the input. Alternatively, you can use the `help-text` attribute. |
Please note, both DOM properties and HTML attributes are shown in the table below. Unless otherwise specified, the property and attribute names are identical.
| Property/Attribute | Reflects | Type | Default |
|---|---|---|---|
name | string | '' | |
value | number | 0 | |
label | string | '' | |
helpText | string | '' | |
disabled | boolean | false | |
min | number | 0 | |
max | number | 100 | |
step | number | 1 | |
tooltip | 'top' | 'bottom' | 'none' | 'top' | |
tooltipFormatter | (value: number) => string | ||
form | string | '' | |
defaultValue | number | 0 | |
validity | |||
validationMessage |
| React Event | Description | Event Detail |
|---|---|---|
| ods-blur | Emitted when the control loses focus. | -- |
| ods-change | Emitted when an alteration to the control's value is committed by the user. | -- |
| ods-focus | Emitted when the control gains focus. | -- |
| ods-input | Emitted when the control receives input. | -- |
| ods-invalid | Emitted when the form control has been checked for validity and its constraints aren't satisfied. | -- |
| Name | Description | Arguments |
|---|---|---|
| focus() | Sets focus on the range. | -- |
| blur() | Removes focus from the range. | -- |
| stepUp() | Increments the value of the range by the value of the step attribute. | -- |
| stepDown() | Decrements the value of the range by the value of the step attribute. | -- |
| checkValidity() | Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. | -- |
| getForm() | Gets the associated form, if one exists. | -- |
| reportValidity() | Checks for validity and shows the browser's validation message if the control is invalid. | -- |
| setCustomValidity() | Sets a custom validation message. Pass an empty string to restore validity. | -- |
| Name | Description |
|---|---|
| form-control | The form control that wraps the label, input, and help text. |
| form-control-label | The label's wrapper. |
| form-control-input | The range's wrapper. |
| form-control-help-text | The help text's wrapper. |
| form-control-error-text | The error text's wrapper. |
| base | The component's base wrapper. |
| input | The internal `<input>` element. |
| tooltip | The range's tooltip. |