Skip to main content
Labels provide accessible text descriptions for form fields.

Basic Usage

Labels can contain text directly or wrap other components.

With Form Fields

Labels are typically paired with inputs and other form controls:

Optional Indicator

Set optional=True to show a muted “optional” hint after the label text. Form.from_model() sets this automatically for non-required fields; for manually built forms, set it yourself on any label.

API Reference

Label Parameters

text
str | None
default:"None"
Label text content. Can be passed as a positional argument.
for_id
str | None
default:"None"
ID of the associated form field element.
optional
bool
default:"False"
When True, displays a muted “optional” indicator after the label text.
css_class
str | None
default:"None"
Additional Tailwind CSS classes appended to the component’s built-in styles.

Protocol Reference

Label
{
  "type": "Label",
  "children?": "[Component]",
  "let?": "object",
  "text?": "string",
  "forId?": "string",
  "optional?": "boolean",
  "cssClass?": "string"
}
For the complete protocol schema, see Label.