For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
FrakmentFrakment

Input

A single-line text input.

Web
Frakment

Your API key is encrypted and stored securely.

input.tsx
import { cn } from "@/lib/utils";

const Input = ({
  className,
  type,
  ...props
}: React.ComponentProps<"input">) => (
  <input
    className={cn(
      "file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
      "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
      "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
      className
    )}
    data-slot="input"
    type={type}
    {...props}
  />
);

export { Input };

Input is a single-line text field for forms and inline editing. It inherits all native <input> attributes and behaviors, and pairs with Field for labels and descriptions.

Installation

Usage

input.tsx
import { Input } from "@/components/ui/input";
tsx
<Input placeholder="Email" type="email" />

Examples

Basic

input-basic.tsx
"use client";

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

export function InputBasic() {
  return <Input className="max-w-xs" placeholder="Enter text" />;
}
tsx
<Input placeholder="Enter text" />

With label

Choose a unique username for your account.

input-field.tsx
"use client";

import { Field, FieldDescription, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";

export function InputField() {
  return (
    <Field className="max-w-xs">
      <FieldLabel htmlFor="input-field-username">Username</FieldLabel>
      <Input
        id="input-field-username"
        placeholder="Enter your username"
        type="text"
      />
      <FieldDescription>
        Choose a unique username for your account.
      </FieldDescription>
    </Field>
  );
}
tsx
<Field>
  <FieldLabel htmlFor="username">Username</FieldLabel>
  <Input id="username" placeholder="Enter your username" />
  <FieldDescription>
    Choose a unique username for your account.
  </FieldDescription>
</Field>

Form

Use FieldGroup for multiple fields with consistent spacing.

We'll send updates to this address.

input-fieldgroup.tsx
"use client";

import { Button } from "@/components/ui/button";
import {
  Field,
  FieldDescription,
  FieldGroup,
  FieldLabel,
} from "@/components/ui/field";
import { Input } from "@/components/ui/input";

export function InputFieldgroup() {
  return (
    <FieldGroup className="max-w-xs">
      <Field>
        <FieldLabel htmlFor="fieldgroup-name">Name</FieldLabel>
        <Input id="fieldgroup-name" placeholder="Jordan Lee" />
      </Field>
      <Field>
        <FieldLabel htmlFor="fieldgroup-email">Email</FieldLabel>
        <Input
          id="fieldgroup-email"
          placeholder="name@example.com"
          type="email"
        />
        <FieldDescription>We'll send updates to this address.</FieldDescription>
      </Field>
      <Field orientation="horizontal">
        <Button type="reset" variant="outline">
          Reset
        </Button>
        <Button type="submit">Submit</Button>
      </Field>
    </FieldGroup>
  );
}
tsx
<FieldGroup>
  <Field>
    <FieldLabel htmlFor="name">Name</FieldLabel>
    <Input id="name" placeholder="Jordan Lee" />
  </Field>
  <Field>
    <FieldLabel htmlFor="email">Email</FieldLabel>
    <Input id="email" type="email" placeholder="name@example.com" />
  </Field>
  <Field orientation="horizontal">
    <Button type="submit">Submit</Button>
  </Field>
</FieldGroup>

Invalid

Set aria-invalid on the input, or data-invalid on the Field wrapper, to trigger destructive styling.

This field contains validation errors.

input-invalid.tsx
"use client";

import { Field, FieldDescription, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";

export function InputInvalid() {
  return (
    <Field className="max-w-xs" data-invalid>
      <FieldLabel htmlFor="input-invalid">Invalid Input</FieldLabel>
      <Input aria-invalid id="input-invalid" placeholder="Error" />
      <FieldDescription>
        This field contains validation errors.
      </FieldDescription>
    </Field>
  );
}
tsx
<Field data-invalid>
  <FieldLabel htmlFor="email">Email</FieldLabel>
  <Input id="email" aria-invalid />
  <FieldDescription>This field contains validation errors.</FieldDescription>
</Field>

Types

tsx
<Input type="email" placeholder="Email" />
<Input type="password" placeholder="Password" />
<Input type="search" placeholder="Search" />
<Input type="file" />

In Context

Email field

input-email.tsx
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";

export function InputEmail() {
  return (
    <div className="mx-auto flex w-full max-w-sm flex-col gap-2">
      <Label htmlFor="email">Email</Label>
      <Input id="email" placeholder="you@example.com" type="email" />
    </div>
  );
}

For an icon inside the input surface, use Input Group:

https://
input-group-demo.tsx
"use client";

import { ArrowRightIcon, Search } from "lucide-react";
import {
  InputGroup,
  InputGroupAddon,
  InputGroupButton,
  InputGroupInput,
  InputGroupText,
} from "@/components/ui/input-group";

export function InputGroupDemo() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-3">
      <InputGroup>
        <InputGroupAddon>
          <Search />
        </InputGroupAddon>
        <InputGroupInput placeholder="Search..." />
      </InputGroup>
      <InputGroup>
        <InputGroupAddon>
          <InputGroupText>https://</InputGroupText>
        </InputGroupAddon>
        <InputGroupInput placeholder="example.com" />
      </InputGroup>
      <InputGroup>
        <InputGroupInput placeholder="Enter email" />
        <InputGroupAddon align="inline-end">
          <InputGroupButton size="icon-xs" variant="default">
            <ArrowRightIcon />
          </InputGroupButton>
        </InputGroupAddon>
      </InputGroup>
    </div>
  );
}

States

StateHow
Default—
Focuskeyboard focus on the field
Invalidaria-invalid="true"
Disableddisabled prop
tsx
<Input aria-invalid="true" placeholder="Email" />
<Input disabled placeholder="Disabled" />

API Reference

Input

Extends React.ComponentProps<"input">.

PropTypeDefaultDescription
typestring"text"Native input type.
placeholderstring—Shown when the input is empty.
valuestring—Controlled value.
defaultValuestring—Uncontrolled initial value.
onChangeReact.ChangeEventHandler<HTMLInputElement>—Fires on every keystroke.
disabledbooleanfalseRemoves the input from the tab order.
aria-invalidboolean—Marks the input as invalid; pair with aria-describedby.

Accessibility

  • Input renders a native <input>. It has no label by default; always pair with a Label or FieldLabel.
  • Use the native type attribute (email, url, tel, number) so mobile keyboards adapt.
  • Set aria-invalid and aria-describedby on error. Do not rely on a red border alone.
  • disabled removes the input from the tab order. For informational values, use readOnly.

Best Practices

  • Always label the input. Placeholders disappear after typing; labels stay.
  • Use the native type. email, url, tel, and number trigger the right keyboard on mobile.
  • Show errors inline. Use aria-invalid and a description below the input, not a toast.
  • Do not disable without reason. Disabled inputs are invisible to screen readers.
  • Cap length with maxLength. Do not rely on server-side validation alone.

Anatomy

input-anatomy.tsx
import { Input } from "@/components/ui/input";

export function InputAnatomy() {
  return (
    <div className="flex flex-col gap-2">
      <Input placeholder="Empty" />
      <Input defaultValue="Filled" />
      <Input aria-invalid placeholder="Invalid" />
    </div>
  );
}
  • Field — 36px height, 1px border, 6px radius
  • Text — 14px, inherits foreground
  • Placeholder — muted-foreground, disappears on input
  • Focus ring — ring-3 in ring color on focus
  • Field — label, description, and error wrapper
  • Input Group — add icons and buttons
  • Input OTP — one-time password input
  • Textarea — multi-line variant