Range β
Accessible range slider that allows easy selection of a value by sliding a handle.
View SourceΒUsage β
css
@import "winduum/src/ui/range/index.css" layer(components);
js
import { setValue } from 'winduum/src/ui/range'
const rangeSlider = document.querySelector('#rangeSlider')
setValue(rangeSlider)
rangeSlider.addEventListener('input', ({ currentTarget }) => setValue(currentTarget))
Variants β
Props β
Tokens β
Installation β
Follow instructions for individual framework usage below
Examples β
Default β
html
<div class="ui-range">
<input type="range" value="0" step="10" max="100" min="0" aria-labelledby="single" id="range-single">
</div>
<output class="before:content-[attr(data-unit)]" data-unit="$" aria-label="Price" id="single">10 000</output>
liquid
<script type="module">
import { setValue, setOutputValue } from 'winduum/src/ui/range/index.js'
const rangeSingle = document.querySelector('#range-single')
const setSingleValue = ({ currentTarget }) => {
setValue(currentTarget)
setOutputValue(currentTarget, document.querySelector('#single'))
}
setSingleValue({ currentTarget: rangeSingle })
rangeSingle.addEventListener('input', setSingleValue)
</script>
vue
<script setup lang="ts">
import { UiRange } from '@/components/ui/progress'
</script>
<template>
<UiRange>
<input type="range" value="0" step="10" max="100" min="0" aria-labelledby="single" id="range-single">
</UiRange>
</template>
jsx
import { UiProgress } from '@/components/ui/progress'
export function Example() {
return (
<UiRange>
<input type="range" value="0" step="10" max="100" min="0" aria-labelledby="single" id="range-single">
</UiRange>
)
}
Multi β
html
<div class="ui-range accent-warning">
<input type="range" value="0" step="100" max="10000" min="0" id="range-from" aria-labelledby="from">
<input type="range" value="10000" step="100" max="10000" min="0" id="range-to" aria-labelledby="to">
</div>
<div class="flex-between items-center">
<output class="before:content-[attr(data-unit)]" data-unit="$" aria-label="Price from" id="from">0</output>
<output class="before:content-[attr(data-unit)]" data-unit="$" aria-label="Price to" id="to">10 000</output>
</div>
liquid
<script type="module">
import { setValue, setOutputValue } from 'winduum/src/ui/range/index.js'
const rangeFrom = document.querySelector('#range-from')
const rangeTo = document.querySelector('#range-to')
const setFromValue = ({ currentTarget }) => {
setValue(currentTarget)
setOutputValue(currentTarget, document.querySelector('#from'))
}
const setToValue = ({ currentTarget }) => {
setValue(currentTarget, {
track: 'end'
})
setOutputValue(currentTarget, document.querySelector('#to'))
}
setFromValue({ currentTarget: rangeFrom })
rangeFrom.addEventListener('input', setFromValue)
setToValue({ currentTarget: rangeTo })
rangeTo.addEventListener('input', setToValue)
</script>
Vertical β
html
<div class="ui-range vertical h-48">
<input type="range" value="0" step="10" max="100" min="0" aria-labelledby="single" id="range-single">
</div>
<output class="before:content-[attr(data-unit)]" data-unit="$" aria-label="Price" id="single">10 000</output>
liquid
<script type="module">
import { setValue, setOutputValue } from 'winduum/src/ui/range/index.js'
const rangeSingle = document.querySelector('#range-single')
const setSingleValue = ({ currentTarget }) => {
setValue(currentTarget)
setOutputValue(currentTarget, document.querySelector('#single'))
}
setSingleValue({ currentTarget: rangeSingle })
rangeSingle.addEventListener('input', setSingleValue)
</script>
Javascript API β
setTrackProperty β
- Type:
(options: TrackOptions, track: 'start' | 'end') => void
- Kind:
sync
TrackOptions β
element β
- Type:
HTMLElement | Element
- Default:
undefined
value β
- Type:
string
- Default:
undefined
max β
- Type:
number
- Default:
undefined
setValue β
- Type:
(target: HTMLInputElement, options: DefaultOptions) => void
- Kind:
sync
DefaultOptions β
selector β
- Type:
string
- Default:
.ui-range
track β
- Type:
string
- Default:
'start' | 'end'
setOutputValue β
- Type:
(target: HTMLInputElement, options: OutputOptions) => void
- Kind:
sync
OutputOptions β
element β
- Type:
HTMLOutputElement
- Default:
null
lang β
- Type:
string
- Default:
document.documentElement.lang
formatOptions β
- Type:
Intl.NumberFormatOptions
- Default:
{ style: 'decimal', minimumFractionDigits: 0, maximumFractionDigits: 0 }