CraftUI

Input

A sunken text field for text, passwords and numbers.

Installation

npx shadcn@latest add @runqora/craft-input

Usage

import { Input } from "@/components/craft/input";

<label htmlFor="name">World name</label>
<Input id="name" placeholder="World name" />;

Examples

States and sizes

Icons

With React Hook Form and Zod

Input forwards its ref to the real input, so register works directly. Submit this form empty to see its error.

Props

Prop

Type

Input also accepts every attribute of an <input>. They go to the input element, while className goes to the field around it.

Accessibility

  • Give every input a visible <label>, or an aria-label when the context already makes its purpose clear.
  • error sets aria-invalid. Link your message to the input with aria-describedby, as the form example does.
  • A red outline isn't the only sign of an error: always show a message too.
  • Icons are decorative. A button placed inside the field needs its own label.

Customization

Change the color of one field's outline by overriding its token.

<Input className="[--craft-outline:#2e6be5]" />

Dependencies

Source

On this page