mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-28 07:04:20 +00:00
54 lines
1.1 KiB
Plaintext
54 lines
1.1 KiB
Plaintext
---
|
|
title: Label
|
|
description: Renders an accessible label associated with controls.
|
|
component: true
|
|
radix:
|
|
link: https://www.radix-ui.com/docs/primitives/components/label
|
|
api: https://www.radix-ui.com/docs/primitives/components/label#api-reference
|
|
---
|
|
|
|
<ComponentExample src="/components/examples/label/demo.tsx" extractClassname>
|
|
<LabelDemo />
|
|
</ComponentExample>
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
npx shadcn-ui add label
|
|
```
|
|
|
|
<Accordion type="single" collapsible>
|
|
<AccordionItem value="manual-installation">
|
|
<AccordionTrigger>Manual Installation</AccordionTrigger>
|
|
<AccordionContent>
|
|
|
|
1. Install the `@radix-ui/react-label` component from radix-ui:
|
|
|
|
```bash
|
|
npm install @radix-ui/react-label
|
|
```
|
|
|
|
2. Copy and paste the following code into your project.
|
|
|
|
<ComponentSource src="/components/ui/label.tsx" />
|
|
|
|
<Callout>
|
|
This is the `<Label />` primitive. You can place it in a file at
|
|
`components/ui/label.tsx`.
|
|
</Callout>
|
|
|
|
</AccordionContent>
|
|
|
|
</AccordionItem>
|
|
</Accordion>
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import { Label } from "@/components/ui/label"
|
|
```
|
|
|
|
```tsx
|
|
<Label htmlFor="email">Your email address</Label>
|
|
```
|