Skip to content

Slider

A Slider allows users to choose from a range of continuous and discrete values. The Slider displays the range of possible values and the Slider’s indicator displays the current value.

Guidelines

Web Components Usage

1. Installation

Install the Astro UXDS Slider package via Command Line (Preferred Method)

sh
npm i -save @astrouxds/rux-slider
npm i -save @astrouxds/rux-slider

You may use Yarn, NPM, or your Node package manager of choice. The --save flag adds this component as a dependency in your package.json file.

Alternatively, download the Astro UXDS Component Library source to your project.

Via CLI:

sh
git clone https://github.com/RocketCommunicationsInc/astro-components.git
git clone https://github.com/RocketCommunicationsInc/astro-components.git

Or, download the Astro UXDS Components as a .zip

2. Import the Astro Slider Web Component

This example assumes you're using the NPM package in node_modules. Otherwise, import the component using the path to the Astro Components directory in your project.

javascript
import { RuxSlider } from '@astrouxds/rux-slider/rux-slider.js'
import { RuxSlider } from '@astrouxds/rux-slider/rux-slider.js'

3. Render the Astro Slider Web Component

Pass properties via attributes similar to the native HTML Input Range attributes:

xml
<rux-slider
  min="0"
  max="400"
  step="5"
  val="200"
  disabled
  >
</rux-slider>
<rux-slider
  min="0"
  max="400"
  step="5"
  val="200"
  disabled
  >
</rux-slider>

Properties

PropertyAttributeDescriptionTypeDefault
axisLabels--Shows tick marks and labels in the order provided and aligns evenly based on the length.string[][]
disableddisabledDetermines if the slider is disabled.booleanfalse
errorTexterror-textThe validation error textstring | undefinedundefined
helpTexthelp-textThe help or explanation textstring | undefinedundefined
labellabelThe slider label text. For HTML content, use the label slot instead.string | undefinedundefined
maxmaxMax value of slider.number100
minminMin value of the slider.number0
minValmin-valIf present, creates a dual-range slider by adding a second thumb.number | undefinedundefined
namenameName of the Input Field for Form Submissionstring''
stepstepStep amount of slider value.number1
strictstrictIn a dual-range slider, disables thumb swapping.booleanfalse
ticksOnlyticks-onlyHides labels and only shows tick marks if axis-labels is provided.booleanfalse
valuevalueCurrent value of the slider. The default value is halfway between the specified minimum and maximum. - HTMLElement/input_type_range> In dual-range, this value should be higher than the min-val.number(this.max! - this.min!) / 2 + this.min!

Events

EventDescriptionType
ruxblurFired when an element has lost focus - HTMLElement/blur_eventCustomEvent<any>
ruxchangeFired when the element's value is altered by the user - HTMLElement/change_eventCustomEvent<any>
ruxinputFired when the value of the input changes - HTMLElement/input_eventCustomEvent<any>

Slots

SlotDescription
"error-text"the error text
"help-text"the help text
"label"The slider label

Shadow Parts

PartDescription
"axis-label"the axis label
"error-text"The error text element
"form-field"The form-field wrapper container
"help-text"The help text element
"input"The input element
"label"The input label when label prop is set
"tick"the tick mark
"tick-container"The container of the tick mark and axis-label

CSS Custom Properties

NameDescription
--slider-track-before-thumb-heightthe height of the track before the thumb

Built with StencilJS