Slider
Single and dual-thumb range controls with marks, tooltips and keyboard support.
Volume: 40%
"use client";
import { useState } from "react";
import { Slider, Text, VStack } from "astralis-ui";
export function SliderDemo() {
const [volume, setVolume] = useState(40);
return (
<VStack gap="3" alignItems="stretch" w="full" maxW="xs">
<Slider value={volume} onChange={setVolume} />
<Text size="xs" color="muted">Volume: {volume}%</Text>
</VStack>
);
}Import#
import { Slider, RangeSlider } from "astralis-ui";Marks#
marks accepts true for auto-marks at every step, or an array with
optional labels for the ones worth naming.
"use client";
import { Slider, Box } from "astralis-ui";
export function SliderMarks() {
return (
<Box w="full" maxW="xs" pb="4">
<Slider
min={0}
max={100}
step={25}
defaultValue={50}
colorScheme="purple"
marks={[
{ value: 0, label: "Off" },
{ value: 25 },
{ value: 50, label: "Balanced" },
{ value: 75 },
{ value: 100, label: "Max" },
]}
/>
</Box>
);
}Range#
RangeSlider is the dual-thumb sibling — same props, tuple value.
Price: $200 – $600
"use client";
import { useState } from "react";
import { RangeSlider, Text, VStack } from "astralis-ui";
export function SliderRange() {
const [range, setRange] = useState<[number, number]>([200, 600]);
return (
<VStack gap="3" alignItems="stretch" w="full" maxW="xs">
<RangeSlider min={0} max={1000} step={50} value={range} onChange={setRange} />
<Text size="xs" color="muted">
Price: ${range[0]} – ${range[1]}
</Text>
</VStack>
);
}Props#
| Prop | Type | Default | Description |
|---|---|---|---|
min / max / step | number | 0 / 100 / 1 | The scale. |
value / defaultValue / onChange | number (Slider) or [number, number] (RangeSlider) | — | Controlled / uncontrolled API. |
marks | boolean | { value, label? }[] | — | Tick marks, optionally labeled. |
showTooltip | boolean | true | Value tooltip on the thumb. |
size | "sm" | "md" | "lg" | "md" | Track and thumb scale. |
colorScheme | all 11 schemes | "brand" | Filled-track and thumb hue. |
invalid / disabled / readOnly | boolean | false | State flags — inherited from Field. |
Keyboard#
| Key | Action |
|---|---|
→ / ↑ | Increase by step |
← / ↓ | Decrease by step |
Home / End | Jump to min / max |
Accessibility#
Thumbs render role="slider" with aria-valuemin/max/now; RangeSlider's
two thumbs are each independently focusable and clamp against each other.