Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Required Label for Solid

The label Email with a destructive asterisk on the same line, marking the field as required.

UI library: Ark UI

Email is the label. A destructive asterisk sits on the same line, after the word.

Use the asterisk when a field must be filled in. If most fields are required, mark the optional ones on a Field label instead. In Solid, Ark UI does not enforce the asterisk.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Label anatomy: label, control, text

Usage

<Label>
    Email <span class="text-destructive">*</span>
  </Label>

FAQ

How is the asterisk marked up?

A span with className="text-destructive" and the character *, after the word Email, inside the Label. There is a space between Email and the span.

Where does the asterisk sit?

On the same line, after the caption. Label is a flex row with gap-2, so the span follows Email.

Where does the red come from?

text-destructive on the span only. The word Email keeps the label's text color. The label itself has no color class.

Does the asterisk mark a field required?

No. The file has no input. The asterisk is visual. Put required on the input as well, or the field is not required to the browser.

How do I point this label at the email input?

Give the input an id and point the label at it. The asterisk span can stay inside the label. Set for to the input's id.

What will a screen reader say for this label?

Email, then the asterisk, because both are text in the label. The span has no aria-label. The file does not add a legend that explains the mark.

API Reference

Label

No extra props in this demo. The rest is on the Label page.