Range
"use client";
import { Field, Range } from "@cherry-design-system/react";
export function Volume() {
return (
<Field label="Volume">
<Range name="volume" min={0} max={100} defaultValue={60} />
</Field>
);
}A slider on a native <input type="range">: keyboard, touch, forms and assistive tech come from the platform. The filled part of the track follows the value. Use it when an approximate value is fine, such as volume or opacity. Use NumberField when the exact number matters.
Examples
Controlled with a readout
"use client";
import { useState } from "react";
import { Field, Range } from "@cherry-design-system/react";
export function Opacity() {
const [value, setValue] = useState(80);
return (
<Field label="Opacity" hint={`${value}%`}>
<Range
min={0}
max={100}
step={5}
value={value}
onChange={(e) => setValue(Number(e.target.value))}
/>
</Field>
);
}Sizes and width
Range stretches to its container by default. Pass fullWidth={false} to size it yourself.
"use client";
import { Field, Range } from "@cherry-design-system/react";
export function Compact() {
return (
<Field label="Zoom">
<Range size="sm" fullWidth={false} min={50} max={200} defaultValue={100} />
</Field>
);
}Properties
Track and thumb size. Defaults to "md".
Error state; set automatically inside a <Field error>.
Stretch to the container width. Defaults to true.
Class for the outer wrapper (className goes to the <input>).
The ref and native <input> attributes (except size and type) go to the <input>.
Styling
Root class cherry-range with data-size (sm, md, lg) and states data-invalid, data-disabled, data-full-width. Part: cherry-range__input. The fill reads the --_ratio custom property (0 to 1), which the component keeps in sync with the value.
Reads --cherry-primary-default for the fill, --cherry-bg-muted for the track, --cherry-elevation-sm for the thumb, --cherry-ring and --cherry-ring-danger.
Accessibility
Native range: arrows step, PageUp and PageDown jump, Home and End go to min and max. Give it a label with Field or aria-label.