Documentation / Forms
Slider
The value slider: a native <input type="range">, made invisible on top of a styled track, fill and thumb. It therefore keeps all the native behaviour — arrows, Page Up / Down, Home / End, screen readers — with the library’s look.
Controlled (value + onValueChange, which receives a number) or not (defaultValue). One value per slider: for a range, use two. valueFormat only formats the display (showValue, showTooltip): for screen readers to announce the same thing, also pass aria-valuetext.
Client component ("use client"). Six semantic colours through color, or free CSS values through trackColor, fillColor and thumbColor.
Examples
Basic usage
Uncontrolled: defaultValue sets the initial position, showValue displays it next to the label.
import { Slider } from "@synertech/ui";
export function Basic() {
return <Slider label="Volume" defaultValue={40} showValue />;
}Controlled, formatted value
onValueChange returns a number; valueFormat dresses up the display and the tooltip.
import { useState } from "react";
import { Slider } from "@synertech/ui";
export function Controlled() {
const [budget, setBudget] = useState(1500);
const format = (value: number) =>
value.toLocaleString("fr-FR", { style: "currency", currency: "EUR", maximumFractionDigits: 0 });
return (
<Slider
label="Budget mensuel"
min={0}
max={5000}
step={100}
value={budget}
onValueChange={setBudget}
showValue
showTooltip
valueFormat={format}
aria-valuetext={format(budget)}
description="Par tranche de 100 €."
/>
);
}Marks
marks takes a list of labelled marks, or true for one mark per step.
import { Slider, type SliderMark } from "@synertech/ui";
const qualityMarks: SliderMark[] = [
{ value: 0, label: "Basse" },
{ value: 50, label: "Moyenne" },
{ value: 100, label: "Haute" },
];
export function Marks() {
return (
<div className="flex flex-col gap-8">
<Slider label="Qualité d’export" defaultValue={50} step={50} marks={qualityMarks} />
<Slider label="Note" min={1} max={5} step={1} defaultValue={4} marks showValue />
</div>
);
}Sizes and colours
size sets the thickness of the track and thumb, color the semantic hue.
import { Slider } from "@synertech/ui";
export function SizesAndColors() {
return (
<div className="flex flex-col gap-6">
<Slider size="sm" color="neutral" label="Petit, neutre" defaultValue={30} />
<Slider size="md" color="success" label="Moyen, succès" defaultValue={55} />
<Slider size="lg" color="warning" label="Grand, avertissement" defaultValue={80} />
<Slider
label="Couleurs libres"
defaultValue={65}
fillColor="#7c3aed"
thumbColor="#7c3aed"
trackColor="#ede9fe"
/>
</div>
);
}Validation and states
A string passed to error shows under the track and turns the slider red; disabled and readOnly freeze it.
import { useState } from "react";
import { Slider } from "@synertech/ui";
export function States() {
const [discount, setDiscount] = useState(35);
return (
<div className="flex flex-col gap-6">
<Slider
label="Remise accordée"
max={50}
value={discount}
onValueChange={setDiscount}
showValue
valueFormat={(v) => `${v} %`}
error={discount > 30 ? "Au-delà de 30 %, l’accord d’un responsable est requis." : false}
/>
<Slider label="Remise validée" defaultValue={20} max={50} showValue readOnly />
<Slider label="Remise (désactivée)" defaultValue={10} max={50} disabled />
</div>
);
}API reference
Components
import { Slider } from "@synertech/ui";Props — SliderProps
| Prop | Type | Default | Description |
|---|---|---|---|
color |
SliderColor |
"primary" |
|
containerClassName |
string |
— | className applied to the outer container. |
defaultValue |
number |
— | Uncontrolled initial value. |
description |
string |
— | Help written below the track; a message passed as |
disabled |
boolean |
false |
|
error |
boolean | string |
— |
|
fillColor |
string |
— | Override the filled portion color. |
label |
string |
— | Field label rendered above the track. |
marks |
boolean | SliderMark[] |
— | Tick marks — an array of marks, or |
max |
number |
100 |
|
min |
number |
0 |
|
onValueChange |
(value: number) => void |
— | Called with the new numeric value whenever it changes. |
readOnly |
boolean |
false |
|
showTooltip |
boolean |
false |
Display a value bubble above the thumb on hover/focus. |
showValue |
boolean |
false |
Display the current value next to the label. |
size |
SliderSize |
"md" |
|
step |
number |
1 |
|
thumbColor |
string |
— | Override the thumb color. |
trackColor |
string |
— | Override the track (rail) background color. |
value |
number |
— | Controlled value. |
valueFormat |
(value: number) => string |
— | Format the displayed value (for |
+ 299 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
Types
SliderMark
Interfaceinterface SliderMark| Field | Type | Default | Description |
|---|---|---|---|
value• |
number |
— | |
label |
ReactNode |
— |
SliderColor
Typetype SliderColor = "primary" | "success" | "warning" | "error" | "info" | "neutral"SliderSize
Typetype SliderSize = "sm" | "md" | "lg"