mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-30 16:14:13 +00:00
55 lines
1.1 KiB
Plaintext
55 lines
1.1 KiB
Plaintext
---
|
|
title: Slider
|
|
description: An input where the user selects a value from within a given range.
|
|
component: true
|
|
radix:
|
|
link: https://www.radix-ui.com/docs/primitives/components/slider
|
|
api: https://www.radix-ui.com/docs/primitives/components/slider#api-reference
|
|
---
|
|
|
|
<ComponentExample src="/components/examples/slider/demo.tsx">
|
|
<SliderDemo />
|
|
</ComponentExample>
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
npx shadcn-ui add slider
|
|
```
|
|
|
|
<Accordion type="single" collapsible>
|
|
<AccordionItem value="manual-installation">
|
|
<AccordionTrigger>Manual Installation</AccordionTrigger>
|
|
<AccordionContent>
|
|
|
|
1. Install the `@radix-ui/react-slider` component from radix-ui:
|
|
|
|
```bash
|
|
npm install @radix-ui/react-slider
|
|
```
|
|
|
|
2. Copy and paste the following code into your project.
|
|
|
|
<ComponentSource src="/components/ui/slider.tsx" />
|
|
|
|
<Callout>
|
|
|
|
This is the `<Slider />` primitive. You can place it in a file at `components/ui/slider.tsx`.
|
|
|
|
</Callout>
|
|
|
|
</AccordionContent>
|
|
|
|
</AccordionItem>
|
|
</Accordion>
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import { Slider } from "@/components/ui/slider"
|
|
```
|
|
|
|
```tsx
|
|
<Slider defaultValue={[33]} max={100} step={1} />
|
|
```
|