Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 2.28 KB

input.md

File metadata and controls

42 lines (30 loc) · 2.28 KB

Input

Takes one line of text.

Example

import { Input } from "@usememos/ui";
import { Search } from "lucide-react";

<Input prefix={<Search />} placeholder="Search notes" aria-label="Search notes" />

Props

interface InputProps extends Omit<BaseInput.Props, "size" | "prefix"> {
  size?: "sm" | "md";
  prefix?: React.ReactNode;        // says what the field is: a search or link icon
  suffix?: React.ReactNode;        // one action on the value (copy, clear), or a unit
  className?: string;              // on the visible box, not the <input>
  style?: React.CSSProperties;     // on the visible box, not the <input>
}

function inputClasses(options?: { size?: "sm" | "md" }): string; // the visible box

Wraps Base UI's Input, so inside a Field it gets its label, description and validity. The ref and every other prop (value, onValueChange, type, disabled, native attributes) go to the <input>. The visible box is a <span> around it that fills its container's width.

Rules

  • Provide a Field.Label or aria-label. Never a placeholder alone.
  • prefix and suffix hold an icon, a short word or a small ghost Button.
  • sm for filters inside panels, md everywhere else.
  • An app's own one-line field, such as a tag input around a native <input>, takes inputClasses() on its box: typing focus keeps the edge unchanged, and aria-invalid="true" or aria-disabled="true" on the box show those states. See Class functions.

Style

  • Enabled fields use flat surface with a quiet 1px edge border. A gray well is reserved for the disabled state.
  • Typed text weight 400; placeholder text-secondary. Typed text follows the size row on every input device: 13px at sm and 14px at md.
  • Hover, focus and press keep the same edge border and surface fill. The caret or text selection indicates typing focus; there is no focus border change, ring or animation. Invalid fields retain their danger edge while focused. Disabled fields use well, a quiet edge and text-disabled text. Forced colors uses a 2px system focus edge. See boundary contrast for the resting edge's contrast tradeoff.
  • The side with a prefix or suffix has 2px less padding.