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.
Preview
Section titled “Preview”<nana-range
aria-label="Volume"
min="0"
max="100"
value="50"
style="min-width: 16rem"
></nana-range> <script lang="ts">
import { NanaRange } from '$lib/components/ui/range';
let budget = $state(45000);
</script>
<div class="w-full max-w-md">
<NanaRange
label="Monthly budget"
bind:value={budget}
min={10000}
max={150000}
step={5000}
showValue
showScale
format={(value) => `KES ${value.toLocaleString()}`}
/>
</div> Installation
Section titled “Installation”Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add range --framework web-componentsnpx @nana-tec/ui add range --framework svelteLands in src/lib/components/ui/range/ as NanaRange.svelte, styled with Tailwind
classes that resolve to the design tokens. Requires Tailwind v4.
Import
Section titled “Import”
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.
Basic usage
Section titled “Basic usage”<nana-range aria-label="Volume" min="0" max="100" value="50" style="min-width:16rem"></nana-range><nana-range
min="0"
max="100"
value="25"
size="sm"
style="min-width: 16rem"
></nana-range>
<nana-range
min="0"
max="100"
value="50"
size="md"
style="min-width: 16rem"
></nana-range> Dual, ticks & states
Section titled “Dual, ticks & states”<nana-range
min="0"
max="100"
value="25,75"
dual
style="min-width: 16rem"
></nana-range>
<nana-range
min="0"
max="100"
value="50"
ticks
show-min-max
style="min-width: 16rem"
></nana-range>
<nana-range
min="0"
max="100"
value="40"
disabled
style="min-width: 16rem"
></nana-range> Variants
Section titled “Variants”The variant attribute sets the track fill — default, filled, or gradient.
<nana-range
min="0"
max="100"
value="50"
variant="default"
style="min-width: 16rem"
></nana-range>
<nana-range
min="0"
max="100"
value="50"
variant="filled"
style="min-width: 16rem"
></nana-range>
<nana-range
min="0"
max="100"
value="50"
variant="gradient"
style="min-width: 16rem"
></nana-range> Errors
Section titled “Errors”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.
<nana-range
aria-label="Budget"
min="0"
max="100"
value="90"
invalid
error-message="Keep the budget under 80."
style="min-width: 16rem"
></nana-range> Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
ariaLabel | aria-label | string | null | null | Accessible label |
disabled | disabled | boolean | false | Disable interaction |
dual | dual | boolean | false | Enable dual-thumb range selection |
errorMessage | error-message | string | '' | Error under the field while it is invalid, in the error part with role="alert". |
invalid | invalid | boolean | false | Marks the field invalid and shows error-message in place of the helper text. |
max | max | number | 100 | Maximum value |
min | min | number | 0 | Minimum value |
orientation | orientation | RangeOrientation | 'horizontal' | Layout orientation |
showInput | show-input | boolean | false | Show linked numeric input fields |
showMinMax | show-min-max | boolean | false | Show min/max labels |
size | size | Size | 'md' | Component size |
step | step | number | 1 | Step increment (0 for continuous) |
ticks | ticks | boolean | false | Show tick marks at every step |
tooltip | tooltip | RangeTooltip | 'none' | Tooltip display mode |
value | value | string | '50' | Current value. Single: "50". Dual: "25,75". |
variant | variant | RangeVariant | 'default' | Visual variant |
Events
| Event | Description |
|---|---|
nana-change | Fired when value settles (detail.value — string or {min, max}) |
nana-input | Fired while dragging (detail.value) |
Slots
| Slot | Description |
|---|---|
(default) | Custom content (appears below the slider) |
prefix | Content before the slider |
suffix | Content after the slider |
CSS parts
| Part | Description |
|---|---|
::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
| Property | Description |
|---|---|
--nana-range-track-height | Track thickness (default: 6px) |
--nana-range-thumb-size | Thumb diameter (default: 20px) |
--nana-range-thumb-hit-size | Smallest pointer target around the thumb, whatever its drawn size (default: 24px) |
--nana-range-track-bg | Track background |
--nana-range-fill-bg | Fill colour |
--nana-range-thumb-bg | Thumb background |
--nana-range-thumb-radius | Thumb shape (default: 50%) |
--nana-range-tooltip-bg | Tooltip background |
--nana-range-tooltip-color | Tooltip text colour |
--nana-range-gradient-from | Gradient start (variant="gradient") |
--nana-range-gradient-to | Gradient end (variant="gradient") |
--nana-range-length | Track length when the slider is vertical |
NanaRange
| Prop | Type | Default |
|---|---|---|
valuebind: | number | 50 |
min | number | 0 |
max | number | 100 |
step | number | 1 |
label | string | |
helperText | string | |
errorMessage | string | |
invalid | boolean | false |
showValue | boolean | false |
showScale | boolean | false |
format | (value: number) => string | String |
onValueChange | (value: number) => void |
Also accepts Omit<HTMLInputAttributes, 'class' | 'value' | 'min' | 'max' | 'step' | 'type'>.