Skip to content

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

Free

Multiple Validation Messages Input for Solid

A Password field set to pass, marked invalid, with three fixed messages: too short, no number, and no special character.

UI library: Ark UI

Password shows pass and the border is in the error color. Under it, a fixed list of three messages, each with an alert icon: too short, no number, and no special character.

Use it after a check that failed more than one rule, so people see every problem at once. A single banner is a weaker Alert. In Solid, Ark UI does not test this password.

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" invalid>
    <FieldLabel>Password</FieldLabel>
    <Input class="bg-background" value="pass" placeholder="Enter password" type="password" />
    <FieldError class="flex flex-col gap-1">
      {messages.map(message => <span class="flex items-center gap-2">
          <CircleAlertIcon aria-hidden="true" class="size-4 shrink-0" />
          {message}
        </span>)}
    </FieldError>
  </Field>

FAQ

How are the messages listed?

One FieldError holds the messages, stacked with flex-col gap-1. Each is a row with a CircleAlertIcon and its text, rendered from a static list of strings.

How is the field marked invalid?

invalid on Field, which sets aria-invalid on the input and gives it a destructive border and ring.

Are the rules checked as I type?

No. The value pass and the messages are fixed, to show the invalid state. Compute the list from the value to make it live, as the Real-time Validation example does.

Are the icons read out?

No. Each CircleAlertIcon has aria-hidden; the text carries the message.

Should I show all rules up front instead?

For passwords, a checklist that ticks off as people type, like the Real-time Validation example, is friendlier than errors after the fact. Use a list of errors when the value comes from elsewhere or is checked on submit.

How is Password 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 invalid. The rest is on the Field page.

Input

Sets value="pass", placeholder="Enter password" and type="password". The rest is on the Input page.