Skip to content

Forms

Input

tsx
"use client";
import { Field, Input } from "@cherry-design-system/react";
import { Mail } from "lucide-react";

export function Email() {
  return (
    <Field label="Email" hint="We never share it.">
      <Input type="email" leadingIcon={<Mail />} placeholder="you@example.com" />
    </Field>
  );
}

A single-line text input for names, emails, URLs and search. Use Textarea for multi-line text, Password for secrets and NumberField for numbers with steppers.

Examples

Sizes

tsx
"use client";
import { Field, Input } from "@cherry-design-system/react";

export function Sizes() {
  return (
    <>
      <Field label="Small">
        <Input size="sm" />
      </Field>
      <Field label="Medium">
        <Input size="md" />
      </Field>
      <Field label="Large">
        <Input size="lg" />
      </Field>
    </>
  );
}

With a suffix

suffix takes any element after the text: a unit, an icon or a button.

tsx
"use client";
import { Field, IconButton, Input } from "@cherry-design-system/react";
import { Copy } from "lucide-react";

export function Domain() {
  return (
    <>
      <Field label="Subdomain">
        <Input name="subdomain" suffix=".example.com" />
      </Field>
      <Field label="API key">
        <Input
          readOnly
          defaultValue="sk_live_1234"
          suffix={<IconButton aria-label="Copy API key" icon={<Copy />} size="sm" />}
        />
      </Field>
    </>
  );
}
tsx
"use client";
import { Field, Input } from "@cherry-design-system/react";
import { Search } from "lucide-react";

export function SearchBox() {
  return (
    <Field label="Search">
      <Input type="search" leadingIcon={<Search />} placeholder="Search projects" />
    </Field>
  );
}

Error

tsx
"use client";
import { Field, Input } from "@cherry-design-system/react";

export function Website() {
  return (
    <Field label="Website" error="Enter a full URL, including https://">
      <Input type="url" defaultValue="example" />
    </Field>
  );
}

Properties

size"sm" | "md" | "lg"

Input size. Defaults to "md".

leadingIconReactNode

Icon before the text, for example <Search />.

suffixReactNode

Element after the text: an icon, a unit or a button.

invalidboolean

Error state; set automatically inside a <Field error>.

wrapperClassNamestring

Class for the outer wrapper (className goes to the <input>).

The ref and every native <input> attribute go to the <input>.

Styling

Root class cherry-input (the wrapper) with data-size (sm, md, lg) and states data-invalid, data-disabled, :focus-within. Parts: cherry-input__control, cherry-input__icon, cherry-input__suffix.

Reads --cherry-bg-canvas, --cherry-border-default, --cherry-border-strong (hover), --cherry-border-focus, --cherry-ring and --cherry-ring-danger.

Accessibility

Always label it: wrap it in Field or pass aria-label. A placeholder is a hint, not a label. invalid (or Field's error) sets aria-invalid and the error is read with the field.