- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Slider
An input where the user selects a value from within a given range.
import { Slider } from "@/components/ui/slider";
export default function Particle() {
return <Slider defaultValue={50} />;
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/slider
Usage
import { Slider, SliderValue } from "@/components/ui/slider";<Slider />API Reference
Slider
Root component. Styled wrapper for Slider.Root from Base UI with default min/max values and edge-aligned thumbs.
| Prop | Type | Default | Description |
|---|---|---|---|
min | number | 0 | Minimum value of the slider |
max | number | 100 | Maximum value of the slider |
haptic | boolean | HapticPattern | false | Vibrates on user-driven steps (drag ticks are throttled to ~25/s) and on pointer release. true uses the selection pattern |
Note: The component sets thumbAlignment="edge" by default, which aligns thumbs to the edge of the track rather than centering them.
Haptics use the useHaptics hook, so they no-op when the device lacks the Vibration API, when the user prefers reduced motion, or when haptics are turned off via setEnabled. Programmatic and form-driven value changes never vibrate.
SliderValue
Displays the current value. Styled wrapper for Slider.Value from Base UI.
Examples
For accessible labelling and validation, prefer using the Field component to wrap checkboxes. See the related example: Slider field.
With Label and Value
Component p-slider-2 not found in registry.
Range Slider
import { Slider } from "@/components/ui/slider";
export default function Particle() {
return <Slider defaultValue={50} disabled />;
}
Vertical
import { Slider } from "@/components/ui/slider";
export default function Particle() {
return (
<div>
<Slider aria-label="Storage size in GB" defaultValue={15} max={35} min={5} />
<div
aria-label="Storage size reference values"
className="mt-4 flex w-full items-center justify-between gap-1 font-medium text-muted-foreground text-xs"
role="group"
>
<span>5 GB</span>
<span>20 GB</span>
<span>35 GB</span>
</div>
</div>
);
}
Form Integration
import { cn } from "@/lib/utils";
import { Slider } from "@/components/ui/slider";
const max = 12;
const skipInterval = 2;
const ticks = [...new Array(max + 1)].map((_, i) => i);
export default function Particle() {
return (
<div>
<Slider aria-label="Value selector" defaultValue={5} max={max} />
<div
aria-label="Value scale from 0 to 12"
className="mt-3 flex w-full items-center justify-between gap-1 px-2.5 font-medium text-muted-foreground text-xs"
role="group"
>
{ticks.map((_, i) => (
<span className="flex w-0 flex-col items-center justify-center gap-2" key={String(i)}>
<span
className={cn("h-1 w-px bg-muted-foreground/72", i % skipInterval !== 0 && "h-0.5")}
/>
<span className={cn(i % skipInterval !== 0 && "opacity-0")}>{i}</span>
</span>
))}
</div>
</div>
);
}
Haptic Feedback
Pass haptic to vibrate on each step and on pointer release. Best felt on a phone; desktop browsers and reduced-motion users get a silent no-op.
import { Slider } from "@/components/ui/slider";
export default function Particle() {
return <Slider defaultValue={50} haptic step={10} />;
}