Peach: Local-first video metadata scraper and media manager.
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "input",
"type": "registry:ui",
"title": "Input",
"description": "Text input with label, hint text, error states, and leading icon support.",
"dependencies": [
"@remixicon/react@^4.9.0",
"react-aria-components@^1.17.0"
],
"registryDependencies": [
"cx"
],
"files": [
{
"path": "components/base/input/hint-text.tsx",
"content": "\"use client\";\n\nimport type { ReactNode, Ref } from \"react\";\nimport type { TextProps as AriaTextProps } from \"react-aria-components\";\nimport { Text as AriaText } from \"react-aria-components\";\nimport { cx } from \"@/utils/cx\";\n\n/**\n * Caption text rendered below a field. Wraps `react-aria-components`' Text\n * so the parent `TextField` automatically wires `aria-describedby` (when\n * `slot=\"description\"`) or `aria-errormessage` (when `slot=\"errorMessage\"`).\n *\n * Visuals come from Figma:\n * - Inter Medium 12/16, letter-spacing 0.15px\n * - color text/secondary (default) or text/error-primary (invalid)\n * - 1px top padding to align with the field's bottom edge\n */\n\nexport interface HintTextProps extends AriaTextProps {\n children: ReactNode;\n isInvalid?: boolean;\n ref?: Ref<HTMLElement>;\n}\n\n/** HintText's classes. Input's `errorMessage` reuses the invalid look. */\nexport function hintTextClassName(isInvalid: boolean, className?: string) {\n return cx(\n \"pt-px text-caption-1-medium text-text-secondary\",\n isInvalid && \"text-text-error-primary\",\n className,\n );\n}\n\nexport function HintText({\n isInvalid = false,\n className,\n ...props\n}: HintTextProps) {\n return (\n <AriaText\n slot={isInvalid ? \"errorMessage\" : \"description\"}\n {...props}\n className={hintTextClassName(isInvalid, className)}\n />\n );\n}\n",
"type": "registry:component",
"target": "components/base/input/hint-text.tsx"
},
{
"path": "components/base/input/input.tsx",
"content": "\"use client\";\n\nimport {\n createContext,\n useContext,\n type ComponentType,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport {\n FieldError as AriaFieldError,\n Group as AriaGroup,\n Input as AriaInput,\n TextField as AriaTextField,\n useLocale,\n} from \"react-aria-components\";\nimport type {\n FieldErrorProps as AriaFieldErrorProps,\n InputProps as AriaInputProps,\n TextFieldProps as AriaTextFieldProps,\n} from \"react-aria-components\";\nimport { Label } from \"./label\";\nimport { HintText, hintTextClassName } from \"./hint-text\";\nimport { cx, sortCx } from \"@/utils/cx\";\n\n/**\n * Figma source: Board UI → Input (node 3665:1849).\n *\n * Architecture (mirrors the Untitled UI / React Aria pattern):\n *\n * InputBase — the styled field shell. Renders <AriaGroup> + adornments\n * + <AriaInput>. State (hover / focus / disabled / invalid)\n * arrives as render-prop booleans from Aria.\n * TextField — wraps <AriaTextField> and a TextFieldContext so size /\n * classes can flow from the composer down into InputBase\n * without prop drilling.\n * Input — opinionated composition: TextField → Label → InputBase\n * → HintText, or React Aria's FieldError for `errorMessage`\n * while the field is invalid. The component most consumers use.\n *\n * Why React Aria:\n * - Label ↔ input ↔ hint association via aria-labelledby / aria-describedby\n * - aria-required, aria-invalid auto-applied\n * - Form library / native validation integration\n * - i18n, RTL, autofill edge cases handled\n * - Render-prop state surfaces `isFocusWithin`, `isHovered`, `isDisabled`,\n * `isInvalid`, `isRequired` — no CSS pseudo gymnastics\n *\n * Visuals stay 1:1 with Figma — see `styles/theme.css` for the tokens.\n */\n\nexport type InputSize = \"medium\" | \"small\";\n\ntype IconComponent = ComponentType<{\n className?: string;\n \"aria-hidden\"?: boolean | \"true\" | \"false\";\n}>;\n\n/* -------------------------------------------------------------------------- */\n/* TextFieldContext */\n/* -------------------------------------------------------------------------- */\n\nexport interface TextFieldContextValue {\n size?: InputSize;\n fieldClassName?: string;\n inputClassName?: string;\n}\n\n/**\n * Shared by every field that wants Input's shell — `Textarea` reads the same\n * size and class overrides out of it, so a composed form stays consistent.\n */\nexport const TextFieldContext = createContext<TextFieldContextValue>({});\n\n/* -------------------------------------------------------------------------- */\n/* TextField */\n/* -------------------------------------------------------------------------- */\n\nexport interface TextFieldProps\n extends Omit<AriaTextFieldProps, \"className\">,\n TextFieldContextValue {\n className?: string;\n children?: ReactNode | ((state: { isRequired: boolean; isInvalid: boolean; isDisabled: boolean; isReadOnly: boolean }) => ReactNode);\n}\n\nexport function TextField({\n size = \"medium\",\n fieldClassName,\n inputClassName,\n className,\n children,\n ...props\n}: TextFieldProps) {\n return (\n <TextFieldContext.Provider value={{ size, fieldClassName, inputClassName }}>\n <AriaTextField\n {...props}\n data-input-size={size}\n className={cx(\n \"group flex h-max w-full flex-col items-start gap-1\",\n className,\n )}\n >\n {children as never /* RAC accepts render-prop children */}\n </AriaTextField>\n </TextFieldContext.Provider>\n );\n}\n\nTextField.displayName = \"TextField\";\n\n/* -------------------------------------------------------------------------- */\n/* InputBase */\n/* -------------------------------------------------------------------------- */\n\nexport interface InputBaseProps extends Omit<AriaInputProps, \"size\" | \"className\"> {\n size?: InputSize;\n className?: string;\n leadingIcon?: IconComponent;\n trailingIcon?: IconComponent;\n /** Custom element rendered in the leading slot (Phone basic uses this). */\n leadingAddon?: ReactNode;\n /** Custom element rendered in the trailing slot, in place of\n * `trailingIcon` (ComboBox's toggle button uses this). */\n trailingAddon?: ReactNode;\n /** Class for the field shell. */\n fieldClassName?: string;\n /** Ref to the <input> element. */\n ref?: Ref<HTMLInputElement>;\n /** Ref to the field shell wrapper. */\n groupRef?: Ref<HTMLDivElement>;\n}\n\nconst inputStyles = sortCx({\n field: [\n \"relative flex w-full items-center\",\n \"rounded-2lg\",\n \"bg-background-tertiary-default text-foreground-icon-tertiary\",\n \"ring-2 ring-inset ring-transparent\",\n \"transition-[background-color,box-shadow,color] duration-[var(--input-transition-ms)] ease\",\n ].join(\" \"),\n\n fieldSize: {\n medium: \"p-2\", // 8px all sides → h auto = 36\n small: \"h-8 px-1.5 py-2\", // 32 / 6 / 8\n },\n\n // When a leadingAddon is present (Phone basic): tighten left padding.\n fieldWithAddonSize: {\n medium: \"h-9 ps-1 pe-2 py-2\", // 36 / 4 / 8 / 8\n small: \"h-8 ps-1 pe-1.5 py-2\",\n },\n\n content: \"flex w-full items-center gap-2 min-w-0\",\n leftSection: \"flex flex-1 items-center gap-0.5 min-w-0\",\n\n input: [\n \"min-w-0 flex-1 bg-transparent border-0 outline-none p-0 m-0\",\n \"font-sans text-body-regular text-text-primary\",\n \"placeholder:text-text-tertiary\",\n \"focus:placeholder:text-text-primary\",\n \"disabled:text-input-disabled-text disabled:placeholder:text-input-disabled-text\",\n \"disabled:cursor-not-allowed\",\n \"aria-invalid:placeholder:text-text-error-placeholder\",\n ].join(\" \"),\n\n icon: \"size-5 shrink-0\",\n});\n\n/** The field shell's state for a render-prop className. */\nexport interface InputFieldState {\n isFocusWithin: boolean;\n isHovered: boolean;\n isDisabled: boolean;\n isInvalid: boolean;\n}\n\n/**\n * The field shell's classes for a state. InputBase uses it, and so do fields\n * whose editable part isn't an <input> (Time Field's segments).\n */\nexport function inputFieldClassName(\n { isFocusWithin, isHovered, isDisabled, isInvalid }: InputFieldState,\n size: InputSize = \"medium\",\n hasAddon = false,\n) {\n return cx(\n inputStyles.field,\n hasAddon ? inputStyles.fieldWithAddonSize[size] : inputStyles.fieldSize[size],\n // Hover: idle, no focus, no disabled, no invalid\n isHovered && !isFocusWithin && !isDisabled && !isInvalid && \"ring-border-button-hover\",\n // Focus wins over hover\n isFocusWithin && !isDisabled && !isInvalid && \"ring-border-button-active\",\n // Disabled\n isDisabled && \"bg-input-disabled-background text-input-disabled-foreground\",\n // Invalid\n isInvalid && \"bg-background-tertiary-error text-foreground-icon-error\",\n );\n}\n\nexport function InputBase({\n size: sizeProp,\n leadingIcon: Leading,\n trailingIcon: Trailing,\n leadingAddon,\n trailingAddon,\n fieldClassName,\n className,\n ref,\n groupRef,\n ...inputProps\n}: InputBaseProps) {\n const { direction } = useLocale();\n const ctx = useContext(TextFieldContext);\n const size: InputSize = sizeProp ?? ctx.size ?? \"medium\";\n const hasAddon = leadingAddon !== undefined && leadingAddon !== null;\n\n return (\n <AriaGroup\n ref={groupRef}\n className={(state) => cx(inputFieldClassName(state, size, hasAddon), ctx.fieldClassName, fieldClassName)}\n >\n <div className={inputStyles.content}>\n <div className={inputStyles.leftSection}>\n {hasAddon ? (\n leadingAddon\n ) : Leading ? (\n <Leading className={inputStyles.icon} aria-hidden />\n ) : null}\n <AriaInput\n ref={ref}\n {...inputProps}\n // Align to the field's start even when email/URL values use LTR.\n className={cx(inputStyles.input, direction === \"rtl\" ? \"pr-1 text-right\" : \"pl-1 text-left\", ctx.inputClassName, className)}\n />\n </div>\n {trailingAddon ?? (Trailing ? (\n <Trailing className={inputStyles.icon} aria-hidden />\n ) : null)}\n </div>\n </AriaGroup>\n );\n}\n\nInputBase.displayName = \"InputBase\";\n\n/* -------------------------------------------------------------------------- */\n/* Input (composed) */\n/* -------------------------------------------------------------------------- */\n\nexport interface InputProps\n extends Omit<TextFieldProps, \"children\">,\n Pick<\n InputBaseProps,\n | \"leadingIcon\"\n | \"trailingIcon\"\n | \"leadingAddon\"\n | \"fieldClassName\"\n | \"groupRef\"\n | \"ref\"\n > {\n label?: ReactNode;\n hint?: ReactNode;\n /**\n * Shown in place of `hint` while the field is invalid, through React Aria's\n * FieldError: the error-message slot the input is described by. Pass a\n * function to render from the validation result, e.g. the browser's own\n * message under the default native validation.\n */\n errorMessage?: AriaFieldErrorProps[\"children\"];\n /** Show an info icon next to the label. Replace with tooltip when Tooltip lands. */\n tooltip?: boolean | string;\n placeholder?: string;\n /** Direction of the editable value, independent of the label and adornments.\n * Email, URL and telephone inputs default to LTR inside RTL forms. */\n inputDir?: \"ltr\" | \"rtl\" | \"auto\";\n}\n\nexport function Input({\n label,\n hint,\n errorMessage,\n tooltip,\n placeholder,\n inputDir,\n leadingIcon,\n trailingIcon,\n leadingAddon,\n fieldClassName,\n ref,\n groupRef,\n className,\n ...textFieldProps\n}: InputProps) {\n return (\n <TextField\n {...textFieldProps}\n className={className}\n // Don't clobber an explicit aria-label; fall back to the placeholder\n // only for unlabelled fields that don't provide one.\n aria-label={\n textFieldProps[\"aria-label\"] ??\n (!label && typeof placeholder === \"string\" ? placeholder : undefined)\n }\n >\n {({ isRequired, isInvalid }) => (\n <>\n {label && (\n <Label\n isRequired={isRequired}\n isInvalid={isInvalid}\n tooltip={tooltip}\n >\n {label}\n </Label>\n )}\n <InputBase\n dir={inputDir ?? ([\"email\", \"url\", \"tel\"].includes(textFieldProps.type ?? \"\") ? \"ltr\" : undefined)}\n ref={ref}\n groupRef={groupRef}\n placeholder={placeholder}\n leadingIcon={leadingIcon}\n trailingIcon={trailingIcon}\n leadingAddon={leadingAddon}\n fieldClassName={fieldClassName}\n />\n {isInvalid && errorMessage != null ? (\n <AriaFieldError className={hintTextClassName(true)}>{errorMessage}</AriaFieldError>\n ) : (\n hint && <HintText isInvalid={isInvalid}>{hint}</HintText>\n )}\n </>\n )}\n </TextField>\n );\n}\n\nInput.displayName = \"Input\";\n",
"type": "registry:component",
"target": "components/base/input/input.tsx"
},
{
"path": "components/base/input/label.tsx",
"content": "\"use client\";\n\nimport type { ReactNode, Ref } from \"react\";\nimport { RiInformationFill } from \"@remixicon/react\";\nimport type { LabelProps as AriaLabelProps } from \"react-aria-components\";\nimport { Label as AriaLabel } from \"react-aria-components\";\nimport { cx } from \"@/utils/cx\";\n\n/**\n * Field label. Wraps `react-aria-components`' Label so the parent `TextField`\n * automatically wires `htmlFor` / `aria-labelledby`.\n *\n * Visuals come from Figma:\n * - Inter Medium 14/20, color text/primary\n * - 2px gap between label + required asterisk + info icon\n * - asterisk is text/error-primary (red/500)\n * - info icon is 16×16 in foreground/icon/quaternary\n *\n * Pass `isRequired` to show the asterisk. Pass `tooltip` to show the info\n * icon (currently a static glyph — when the Tooltip component lands it'll\n * wire up here).\n */\n\nexport interface LabelProps extends AriaLabelProps {\n children: ReactNode;\n isRequired?: boolean;\n /** Reserved for invalid-aware styling (asterisk color, etc.) once we need it. */\n isInvalid?: boolean;\n /** Show the info icon next to the label. */\n tooltip?: boolean | string;\n ref?: Ref<HTMLLabelElement>;\n}\n\nexport function Label({\n isRequired = false,\n isInvalid: _isInvalid,\n tooltip,\n className,\n children,\n ...props\n}: LabelProps) {\n void _isInvalid;\n return (\n <AriaLabel\n data-label=\"true\"\n {...props}\n className={cx(\n \"flex cursor-default items-center gap-0.5\",\n \"text-body-medium text-text-primary\",\n className,\n )}\n >\n {children}\n {isRequired && (\n <span\n aria-hidden=\"true\"\n className=\"text-body-medium text-text-error-primary\"\n >\n *\n </span>\n )}\n {tooltip && (\n <RiInformationFill\n className=\"size-4 shrink-0 text-foreground-icon-quaternary\"\n aria-hidden\n />\n )}\n </AriaLabel>\n );\n}\n",
"type": "registry:component",
"target": "components/base/input/label.tsx"
}
],
"meta": {
"docsUrl": "https://www.boardui.com/components/input",
"example": "import { Input } from \"@/components/base/input/input\";\nimport { RiUserSmileLine, RiQuestionLine } from \"@remixicon/react\";\n\nexport function Example() {\n return (\n <Input\n label=\"Email\"\n type=\"email\"\n isRequired\n tooltip\n placeholder=\"Enter your email\"\n hint=\"This is a hint about this input.\"\n errorMessage=\"Enter a valid email address.\"\n leadingIcon={RiUserSmileLine}\n trailingIcon={RiQuestionLine}\n />\n );\n}",
"snippets": [
{
"label": "size",
"code": "// medium (default, 36px) and small (32px).\n<Input size=\"medium\" label=\"Email\" placeholder=\"Enter your email\" /* … */ />\n<Input size=\"small\" label=\"Email\" placeholder=\"Enter your email\" /* … */ />"
},
{
"label": "states",
"code": "// Hover / focus cross-fade the ring automatically. isDisabled and\n// isInvalid override them and repaint the field, hint and label.\n<Input label=\"Email\" placeholder=\"Enter your email\" /* default */ />\n<Input label=\"Email\" value=\"[email protected]\" /* filled */ />\n<Input label=\"Email\" placeholder=\"Enter your email\" isDisabled />\n<Input label=\"Email\" value=\"not-a-real-email\" isInvalid />"
},
{
"label": "error message",
"code": "// errorMessage replaces the hint while the field is invalid. With isRequired\n// alone, React Aria validates natively on submit: it blocks the form, marks\n// the field invalid and focuses it, without the browser's own bubble.\n<form onSubmit={save}>\n <Input\n label=\"Name\"\n isRequired\n placeholder=\"Enter your name\"\n hint=\"Shown on your profile.\"\n errorMessage=\"Enter your name.\"\n />\n <Button type=\"submit\" size=\"small\">Save</Button>\n</form>\n\n// validationBehavior=\"aria\": the form always submits, and the field is\n// invalid only when you say so.\n<Input\n label=\"Name\"\n validationBehavior=\"aria\"\n isInvalid={submitted && !name}\n value={name}\n onChange={setName}\n errorMessage=\"Enter your name.\"\n/>"
},
{
"label": "phone",
"code": "import * as Flags from \"country-flag-icons/react/3x2\";\nimport { getCountryDataList } from \"countries-list\";\nimport { Select, SelectItem } from \"@/components/base/select/select\";\n\n// Real ISO countries that ship a flag + a dial code, sorted by name.\nconst COUNTRIES = getCountryDataList()\n .filter((c) => Flags[c.iso2] && c.phone.length > 0)\n .map((c) => ({ iso2: c.iso2, name: c.name, dial: c.phone[0] }))\n .sort((a, b) => a.name.localeCompare(b.name));\n\n// The country-code Select goes in the input's leading addon slot.\n<Input\n label=\"Phone Number\"\n placeholder=\"(123) 000-0000\"\n leadingAddon={<CountryCodeSelect />}\n trailingIcon={RiQuestionLine}\n/>\n\nfunction CountryCodeSelect() {\n const [iso2, setIso2] = useState(\"US\");\n const dial = COUNTRIES.find((c) => c.iso2 === iso2)?.dial;\n return (\n <Select\n aria-label=\"Country code\"\n selectedKey={iso2}\n onSelectionChange={(key) => setIso2(String(key))}\n triggerClassName=\"rounded-lg px-1.5 py-1\"\n popoverClassName=\"w-[220px]\"\n renderValue={() => <><Flag iso2={iso2} /> +{dial}</>}\n >\n {COUNTRIES.map((c) => (\n <SelectItem key={c.iso2} id={c.iso2} textValue={c.name}>\n <Flag iso2={c.iso2} />\n <span className=\"flex-1 truncate\">{c.name}</span>\n <span className=\"text-text-tertiary\">+{c.dial}</span>\n </SelectItem>\n ))}\n </Select>\n );\n}"
}
]
}
}