Label

A form label. htmlFor is the point — clicking it focuses the control, and a screen reader announces the two together.

src/components/ui/label.tsx

About

From the component's own source, where it was written.

A form label. htmlFor is the point — clicking it focuses the control, and a screen reader announces the two together.

Install

npx astralyx-ui add label

Usage

import { Label } from '@/components/ui/label'

<Label htmlFor="email" required>Email</Label>
<Input id="email" type="email" />

Composer

Change the props and the source below follows.

Props
tsx
<Label htmlFor="email">Email address</Label>
<Input id="email" />

Examples

With a field

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

Label

A form label. htmlFor is the point — clicking it focuses the control, and a screen reader announces the two together.

Extends ComponentProps<'label'>.

PropTypeDefaultDescription
requiredbooleanfalseAppends a destructive asterisk, hidden from assistive tech since the control carries required itself.
htmlForstring—Id of the control this labels. Without it the click-to-focus and the announcement are both lost.