Skip to content

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

Free

Required Field Input for Vue

A Full Name field with a destructive asterisk, a prompt to enter a full name, and a line under it that says the field is required.

UI library: Ark UI

Full Name has an asterisk in the destructive color, and the placeholder asks for a full name. Under the field, the line says it is required.

Use it when the form cannot be sent without this value. The browser blocks an empty submit. Your own wording still belongs on the Field. In Vue, Ark UI does not supply that error text.

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

Input anatomy: input, placeholder, value, caret

Usage

<Field class="w-full max-w-sm" :required="true">
  <FieldLabel>
    Full Name<span aria-hidden="true" class="text-destructive">*</span>
  </FieldLabel>
  <Input class="bg-background" placeholder="Enter your full name" type="text" />
  <FieldDescription>* Required field</FieldDescription>
</Field>

FAQ

How is the asterisk shown?

A span with text-destructive inside FieldLabel. It has aria-hidden, because the input's required state already tells assistive technology the field is required.

Where is required set?

On Field, which marks the input inside it required.

What does required do when the form is submitted?

The browser blocks the submit while the field is empty and shows its own message. Screen readers announce the field as required.

Why explain the asterisk?

Not everyone knows the convention. The description, * Required field, says it once; in a longer form, put the note at the top.

How do I show my own error message?

Mark the field invalid and put the message in FieldError, as the Error State example does. The field turns destructive and the error shows under the input.

How is Full Name tied to the field?

Clicking the label focuses the field, and screen readers announce it with the field. Field links FieldLabel to the input inside it, so there is no id to match.

API Reference

Field

Sets required. The rest is on the Field page.

Input

Sets placeholder="Enter your full name" and type="text". The rest is on the Input page.