Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Label for Astro

Native Astro labels that name and focus form controls.

Installation

bunx --bun shadcn@latest add @gnostic/label

Usage

import { Label } from "@/components/ui/label"
<Label for="email">Email</Label>

Notes

  • Match for on Label with the target control id.
  • Use Label directly for simple forms and one-off controls.
  • When you need descriptions or validation, prefer Field and FieldLabel.

Example

<Label for="terms">Accept terms and conditions</Label>

API Reference

Read the installed source for the complete prop types.

When to use Label

Set for to the ID of the control being named. Keep the label visible and describe the value the user must provide. Use FieldLabel inside a larger Field composition when that layout is required.

Keyboard and behavior

A native label can focus its associated input and increase the usable click area. It does not make a missing or duplicate ID valid. Check every label-control pair after rendering repeated fields.

Theme and layout

Typography follows the shared form style. Required and optional wording should be text, not only a colored mark. Disabled appearance should agree with the associated control.