ClickorKeyboard shortcut Alt + L

Dragto resize

Nord Design System SearchDeveloperDeveloperGetting startedUsing Web ComponentsWebfontsCDNLocalizationCSS Framework Legacy ESLint PluginWorking with AIFAQDesignDesignGetting startedFoundationsThemesBrand assetsToolsComponentsComponentsAccordion New Aside New Autocomplete New AvatarBadgeBanner Updated ButtonButton GroupCalendar Updated CardCheckbox Updated Collapsible New Combobox New Command MenuDate Picker Updated Date Range Picker New DividerDrawerDropdownEmpty StateField New FieldsetFilter Bar New FooterHeaderIconInput Updated Item New Kbd New LayoutMessageMeter New ModalNavigationNotificationNumber Field New Otp Field New Outline New Pagination New Popout Updated ProgressProgress BarQrcodeRadio Updated Range Updated Scroll Area New Segmented ControlSelect Updated SkeletonSpinnerStackTabTableTagTextarea Updated Time Picker New ToastToggle Updated TooltipTop BarTruncate New Visually HiddenDesign TokensDesign TokensTailwind CSSTailwind CSSBlocksBlocksTemplatesTemplatesIconsIconsPlaygroundPlaygroundLatest UpdatesLatest UpdatesChangelogChangelogMigration guidesMigration guides
GitHub

Clickto expandKeyboard shortcut Alt + L

Range Updated

Open in Storybook

Lets users specify a numeric value using a slider between a minimum and maximum.

Loading...

Usage

Range lets users pick a numeric value with a slider that must be no less than a given minimum and no more than a given maximum. Set min, max and step to define the allowed values, and value for the initial position.

The range renders its built-in label, hint and error on its own. Wrapped in a Field, the Field takes over with a Field Label, Field Description and Field Error, and the built-in versions step aside automatically.

import "@nordhealth/components/lib/Range"
import "@nordhealth/components/lib/Field"
import "@nordhealth/components/lib/FieldLabel"
import "@nordhealth/components/lib/FieldDescription"

Standalone or inside a Field

Use the control on its own with its built-in label, hint and error, or wrap it in a Field — the Field then provides the labelling. Both render the same control:

InlineWith Field

Examples

Range and step

Use min, max and step to control the bounds and increment of the slider.

Steps

Use step to constrain the value to fixed increments as the user drags the thumb.

Unit

Display a unit alongside the value to clarify what the number represents.

Hint

Add a Field Hint to give the user extra guidance about the field.

Required

Set required on the Field Label to show the required indicator and mark the control required.

Custom thumb size

Adjust the size of the draggable thumb with a CSS custom property.

Custom track size

Adjust the thickness of the track with a CSS custom property.

Responsive

The range adapts to the available space and remains usable across viewport sizes.

Error

Show validation with a Field Error and mark the Field invalid.

Disabled and read-only

A disabled range cannot be focused or changed and is excluded from form submission. A readonly range can be focused but not changed, and its value is still submitted.

Hidden label

Every range needs an accessible name. To hide the label visually while keeping it available to assistive technology, set hide-label on the range and connect a Field Label with for. Inside a Field, a Field Label provides this instead.

Expand

Use expand to make the range fill the width of its container.

RTL

Range follows the document or container direction. Toggle the direction to see the layout mirror.

Accessibility

  • Always give the range an accessible name with a Field Label connected via for. If a visible label doesn't suit the layout, set hide-label on the range so it keeps an accessible name for screen reader users.
  • The slider is keyboard operable: arrow keys move the value by step between min and max, and the current value is exposed to assistive technology.
  • Convey validation with a Field Error rather than colour alone — it is associated with the range and announced to assistive technology.
  • Mark required fields by setting required on the Field Label; it shows the indicator and marks the control required.
  • Prefer readonly over disabled when the value is still relevant but not adjustable, as disabled controls are removed from the tab order and not submitted with the form.

API reference

Range

Range input 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.

<nord-accordion></nord-accordion>

Props

PropertyAttribute Description TypeDefault
minminMinimum value for the range slider.number0
maxmaxMaximum value for the range slider.number10
stepstepStep amount for the range slider.number1
expandexpandControls whether the input expands to fill the width of its container.booleanfalse
placeholderplaceholderPlaceholder text to display within the control.string | undefined
requiredrequiredDetermines whether the control is required or not. A required control is announced as such to assistive technology and, inside a <nord-field>, drives the required indicator on the <nord-field-label>. When using this property you need to also set “novalidate” attribute on a form element to prevent browser from displaying its own validation errors.booleanfalse
autocompleteautocompleteSpecifies the data type of the field, so that the browser may attempt to fill out the field automatically on behalf of the user.AutocompleteAttribute'off'
readonlyreadonlyMakes the component readonly, so that it is not editable. Readonly differs from disabled in that readonly fields are still focusable and will be submitted with a form.booleanfalse
disableddisabledMakes the component disabled. This prevents users from being able to interact with the component, and conveys its inactive state to assistive technologies.booleanfalse
namenameThe name of the form component.string | undefined
valuevalueThe value of the form component.string''
formformGets the form, if any, associated with the form element. The setter accepts a string, which is the id of the form.HTMLFormElement | null

Field properties

PropertyAttribute Description TypeDefault
labellabelLabel for the control. Ignored when the control is wrapped in a <nord-field>, which provides the label via <nord-field-label>.string''
hinthintOptional hint text shown with the control. Ignored inside a <nord-field>, which provides it via <nord-field-description>.string | undefined
hintBelowhint-belowRenders the hint below the control and any error instead of below the label.booleanfalse
hideLabelhide-labelVisually hide the label, but still expose it to assistive technologies.booleanfalse
errorerrorOptional error shown with the control. Ignored inside a <nord-field>, which provides it via <nord-field-error>.string | undefined
hideRequiredhide-requiredVisually hide the required indicator, but still expose the required state to assistive technologies.booleanfalse

Slots

Slot name Description
labelUse when a label requires more than plain text.
hintOptional slot that holds hint text for the input.
errorOptional slot that holds error text for the input.

Methods

Method nameParameters Description
focus(options?: FocusOptions) => voidoptions: An object which controls aspects of the focusing process.Programmatically move focus to the component.
blur() => voidN/AProgrammatically remove focus from the component.
click() => voidN/AProgrammatically simulates a click on the component.
EventDetail TypeDescription
inputNordEventFired as the user types into the input.
changeNordEventFired whenever the input's value is changed via user interaction.

CSS Properties

CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.

PropertyDescriptionDefault
--n-range-thumb-sizeControls the size of the thumb.20px
--n-range-track-color-activeControls the color of the portion of the track that represents the current value.var(--n-color-accent)
--n-range-track-color-inactiveControls the color of the portion of the track that represents the remaining value.var(--n-color-border-strong)
--n-range-track-sizeControls the height of the track.3px
Design guidelinesFor designers

Usage

This section includes guidelines for designers and developers about the usage of this component in different contexts.

Do

  • Use to let user specify a numeric value using a slider.
  • Use when the accuracy of the numeric value entered isn’t important.
  • Always use with a label, even if that label is hidden.

Don’t

  • Don’t use when the accuracy of the numeric value entered is important.
  • For entering arbitrary numeric values. Use input component instead.

Hint placement

Hint text is rendered above the control by default to preserve existing behavior for current consumers. Use the hint-below property to opt in to rendering the hint below the control and any error.

This is a non-breaking rollout for teams adopting the new layout gradually. Existing integrations keep the current placement unless hint-below is explicitly set.

Content guidelines

Range labels act as a title for the range input. Labels should typically be short and in noun form:

Lightness percentage
What is the lightness percentage?

When writing range labels, always write them in sentence case, not title case. The first word should be capitalized and the rest lowercase (unless a proper noun):

Item price
Item Price

Do not use colons in range label:

Color depth
Color depth: