DS0
Components

Label

Accessible label for form inputs with consistent styling.

Overview

Label renders a semantic <label> element for form inputs. It supports required field indicators and disabled states while maintaining accessibility through proper htmlFor association.

Choose a unique username.

Usage


export function Example() {
  return (
    <>
      <Label htmlFor="email">Email</Label>
      <input id="email" type="email" />
    </>
  );
}

Required

<Label htmlFor="email" required>Email Address</Label>

Sizes

<Label htmlFor="a" size="sm">Small label</Label>
<Label htmlFor="b" size="md">Medium label (default)</Label>

Accessibility

  • Always renders a <label> element
  • htmlFor must match the associated input's id
  • When required, appends a visual * and screen-reader-only "required" text

API Reference

PropTypeDefaultDescription
htmlForstringID of the associated input (required)
requiredbooleanfalseShows required indicator
disabledbooleanfalseApplies muted styling
size'sm' | 'md''md'Label size
classNamestringAdditional CSS classes
ComponentWhen to Use Instead
TextFor general text content
HeadingFor headings and titles

On this page