Forms · astro-ui · Label

Label

Form label with required/disabled states and two sizes.

Label renders a semantic <label> tied to a control via for. Required adds a visual marker; disabled dims the text to match a disabled control.

Features

  • Native <label> association via for
  • required marker
  • disabled state matches disabled inputs
  • 2 sizes

Usage

---
import { Label, Input } from "astro-ui";
---

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

Demos

Basic

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

API

Props

PropTypeDefaultDescription
forstring—Must match the control's id.
requiredbooleanfalseAdds the required marker.
disabledbooleanfalseDimmed text state.
size"sm" | "md""md"Text scale.
classstring—Merged via cn(); Tailwind classes welcome.
idstring—Element id.

Accessibility

Implemented accessibility features — semantics, ARIA wiring, and keyboard behavior that ship with the component.

  • Native <label> association; aria-required support for required fields

FAQ

Why not just wrap the input?

Wrapping works, but explicit for/id keeps the association when the control isn't a direct child (grids, portals) and is what this component enforces.

Changelog

Version history mentioning Label.

v0.1.0 — 2026-11-11
added
  • Forms (18): Autocomplete, Combobox, Label, Field, Input, InputGroup, Textarea, Select, Checkbox, Radio, Switch, Toggle, ToggleGroup, RadioGroup, Rating, Slider, DatePicker, TimePicker.