Range

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.

Slots

NameDescription
labelThe range's label. Alternatively, you can use the `label` attribute.
help-textText that describes how to use the input. Alternatively, you can use the `help-text` attribute.

Properties

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/AttributeReflectsTypeDefault
name
string''
value
number0
label
string''
helpText
help-text
string''
disabled
booleanfalse
min
number0
max
number100
step
number1
tooltip
'top' | 'bottom' | 'none''top'
tooltipFormatter
(value: number) => string
form
string''
defaultValue
number0
validity
validationMessage

Events

React EventDescriptionEvent Detail
ods-blurEmitted when the control loses focus.--
ods-changeEmitted when an alteration to the control's value is committed by the user.--
ods-focusEmitted when the control gains focus.--
ods-inputEmitted when the control receives input.--
ods-invalidEmitted when the form control has been checked for validity and its constraints aren't satisfied.--

Methods

NameDescriptionArguments
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.--

Parts

NameDescription
form-controlThe form control that wraps the label, input, and help text.
form-control-labelThe label's wrapper.
form-control-inputThe range's wrapper.
form-control-help-textThe help text's wrapper.
form-control-error-textThe error text's wrapper.
baseThe component's base wrapper.
inputThe internal `<input>` element.
tooltipThe range's tooltip.

Search