Skip to content
Nana UI

Forms & Inputs

Range

A range/slider component supporting single and dual-thumb selection, vertical orientation, stepped and continuous modes, tooltips, tick marks, and linked numeric inputs.

View .md Download
KES 45,000

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add range --framework web-components
npx @nana-tec/ui add range --framework svelte

Lands in src/lib/components/ui/range/ as NanaRange.svelte, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and each component downloads only the first time a page uses it:

import "@nana-tec/ui-components/autoloader";
import "@nana-tec/ui-components/theme";

The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.

Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:

import "@nana-tec/ui-components/range";

Copied in with npx @nana-tec/ui add range? Import your project's own @/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.

<script lang="ts">
import { NanaRange } from '$lib/components/ui/range';
let volume = $state(40);
</script>
<NanaRange label="Volume" bind:value={volume} showValue />

A native <input type="range">, so keyboard, touch and forms come from the browser. format shapes the shown value and what screen readers announce.

<nana-range aria-label="Volume" min="0" max="100" value="50" style="min-width:16rem"></nana-range>

The variant attribute sets the track fill — default, filled, or gradient.

Set invalid to mark it invalid. error-message shows beneath it only while invalid is set, and is linked to the control as its description.

Properties

PropertyAttributeTypeDefaultDescription
ariaLabelaria-labelstring | nullnullAccessible label
disableddisabledbooleanfalseDisable interaction
dualdualbooleanfalseEnable dual-thumb range selection
errorMessageerror-messagestring''Error under the field while it is invalid, in the error part with role="alert".
invalidinvalidbooleanfalseMarks the field invalid and shows error-message in place of the helper text.
maxmaxnumber100Maximum value
minminnumber0Minimum value
orientationorientationRangeOrientation'horizontal'Layout orientation
showInputshow-inputbooleanfalseShow linked numeric input fields
showMinMaxshow-min-maxbooleanfalseShow min/max labels
sizesizeSize'md'Component size
stepstepnumber1Step increment (0 for continuous)
ticksticksbooleanfalseShow tick marks at every step
tooltiptooltipRangeTooltip'none'Tooltip display mode
valuevaluestring'50'Current value. Single: "50". Dual: "25,75".
variantvariantRangeVariant'default'Visual variant

Events

EventDescription
nana-changeFired when value settles (detail.value — string or {min, max})
nana-inputFired while dragging (detail.value)

Slots

SlotDescription
(default)Custom content (appears below the slider)
prefixContent before the slider
suffixContent after the slider

CSS parts

PartDescription
::part(base)The root container
::part(track)The track element
::part(fill)The active fill portion
::part(thumb)A draggable handle
::part(tooltip)The value tooltip
::part(label-row)The label row
::part(label-min)The label min
::part(label-max)The label max
::part(slider-wrapper)The slider wrapper
::part(ticks)The ticks
::part(input-row)The input row
::part(range-inputs)The range inputs
::part(sep)The sep
::part(tick)The tick; carries active
::part(input-low)The field for the low value
::part(input-high)The field for the high value
::part(input-value)The field for the value
::part(error)The error message, shown while invalid is set

CSS custom properties

PropertyDescription
--nana-range-track-heightTrack thickness (default: 6px)
--nana-range-thumb-sizeThumb diameter (default: 20px)
--nana-range-thumb-hit-sizeSmallest pointer target around the thumb, whatever its drawn size (default: 24px)
--nana-range-track-bgTrack background
--nana-range-fill-bgFill colour
--nana-range-thumb-bgThumb background
--nana-range-thumb-radiusThumb shape (default: 50%)
--nana-range-tooltip-bgTooltip background
--nana-range-tooltip-colorTooltip text colour
--nana-range-gradient-fromGradient start (variant="gradient")
--nana-range-gradient-toGradient end (variant="gradient")
--nana-range-lengthTrack length when the slider is vertical

NanaRange

PropTypeDefault
valuebind:number50
minnumber0
maxnumber100
stepnumber1
labelstring
helperTextstring
errorMessagestring
invalidbooleanfalse
showValuebooleanfalse
showScalebooleanfalse
format(value: number) => stringString
onValueChange(value: number) => void

Also accepts Omit<HTMLInputAttributes, 'class' | 'value' | 'min' | 'max' | 'step' | 'type'>.