Skip to content

Input

Frosted text field with label, hint, error state, leading icon, trailing slot (button, kbd, unit), rounded or pill shape and two sizes. Focus brightens the glass and adds a soft violet halo.

glass/ui/input
Open ↗

Source

import { useId, type InputHTMLAttributes, type ReactNode } from "react";
import { cn } from "@/lib/utils";

export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
  label: string;
  hideLabel?: boolean;
  hint?: string;
  error?: string;
  leftIcon?: ReactNode;
  /** Element at the end (button, unit, kbd). */
  trailing?: ReactNode;
  size?: "md" | "lg";
  /** Pill-shaped field (search bars, newsletter). */
  pill?: boolean;
  containerClassName?: string;
}

export function Input({
  label,
  hideLabel = false,
  hint,
  error,
  leftIcon,
  trailing,
  size = "md",
  pill = false,
  id,
  disabled,
  className,
  containerClassName,
  ...props
}: InputProps) {
  const autoId = useId();
  const inputId = id ?? autoId;
  const hintId = `${inputId}-hint`;
  const errorId = `${inputId}-error`;
  const describedBy = [hint && !error && hintId, error && errorId].filter(Boolean).join(" ") || undefined;

  return (
    <div className={cn("flex flex-col gap-2", containerClassName)}>
      <label htmlFor={inputId} className={cn("text-sm font-semibold", hideLabel && "sr-only")}>
        {label}
      </label>
      <div
        className={cn(
          "da-transition flex items-center gap-2 border border-da-border-strong/60 bg-da-input text-da-fg shadow-da-sm backdrop-blur-da backdrop-saturate-150",
          "hover:border-da-border-strong focus-within:border-da-primary/60 focus-within:bg-da-surface focus-within:ring-4 focus-within:ring-da-primary/15",
          error && "border-da-danger/70 focus-within:border-da-danger focus-within:ring-da-danger/15 hover:border-da-danger",
          pill ? "rounded-da-pill" : "rounded-da-md",
          size === "md" ? "h-11 px-3.5 text-sm" : "h-13 px-4 text-base",
          disabled && "opacity-55",
        )}
      >
        {leftIcon && (
          <span aria-hidden className="shrink-0 text-da-muted-fg [&_svg]:size-4">
            {leftIcon}
          </span>
        )}
        <input
          id={inputId}
          disabled={disabled}
          aria-invalid={error ? true : undefined}
          aria-describedby={describedBy}
          className={cn("h-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-da-muted-fg disabled:cursor-not-allowed", className)}
          {...props}
        />
        {trailing && <span className="-mr-1.5 flex shrink-0 items-center text-da-muted-fg">{trailing}</span>}
      </div>
      {hint && !error && (
        <p id={hintId} className="text-[13px] text-da-muted-fg">
          {hint}
        </p>
      )}
      {error && (
        <p id={errorId} className="flex items-center gap-1.5 text-[13px] font-medium text-da-danger">
          <span aria-hidden className="grid size-4 place-items-center rounded-full bg-da-danger text-[10px] font-bold text-da-danger-fg">
            !
          </span>
          {error}
        </p>
      )}
    </div>
  );
}

export default Input;

modules/glass/ui/input/index.tsx

Props

PropTypeDefaultDescription
label*string—Visible label (sr-only with hideLabel).
hideLabelbooleanfalseVisually hide the label.
hintstring—Helper text (aria-describedby).
errorstring—Error message; sets aria-invalid.
leftIconReactNode—Decorative leading icon.
trailingReactNode—Element at the end of the field.
size"md" | "lg""md"Height preset.
pillbooleanfalseFully rounded shape.
...restInputHTMLAttributes<HTMLInputElement>—Native input attributes.

Other input variants in Glass

Input in other art directions

Input

Labelled text field with hint, error state, leading icon, suffix slot and two sizes. The field presses into its shadow on focus; errors switch to a red stroke with an explicit message.

BrutalistInput

Number Stepper

Numeric input flanked by chunky yellow − / + buttons (disabled at bounds), big display-font value, optional unit suffix; clamps typed values to min/max.

BrutalistInput

OTP Input

One-time-code input: ruled digit squares (split 3+3 for six digits) that turn yellow and press in on focus; auto-advance, backspace and arrow navigation, paste of the full code, completion callback and error state.

BrutalistInput

Textarea

Labelled multi-line field with a live character counter chip that turns orange near the limit, hint and error states; presses into its shadow on focus.

BrutalistInput

Input

Hairline text field with label (auto "Optional" marker), hint, error with icon, leading icon, text prefix, trailing slot (unit, kbd) and indigo focus ring. Two sizes.

MinimalInput

Search Input

Search field with leading icon, “/” keycap hint that focuses the field, clear button (Escape clears too) and a loading spinner state. Two sizes, controlled or uncontrolled.

MinimalInput

Select Menu

Labelled select built on Radix Select: bordered trigger with chevrons, portalled popover with optional icons, descriptions, groups, separators, disabled items and a check on the selected one.

MinimalInput

Switch Field

Settings row with label and description on the left and a Radix Switch on the right; plain (for divided lists) or bordered card that highlights when on. Disabled state.

MinimalInput

Checkbox Group

Settings checkboxes as ruled rows: square ink check boxes (native inputs), label and muted description; the whole row is clickable.

Mono CleanInput

Input

Underline field: mono uppercase label, a borderless input on a single bottom hairline that turns ink (2px) on focus, optional prefix, hint or red error.

Mono CleanInput

Search Input

Search field with live results: hairline-bordered input with icon and ⌘K hint; matches appear in a ruled list below with the query highlighted and a mono kind label; empty state included.

Mono CleanInput

Select Field

Native select styled as an underline field with a mono label and a custom chevron — reliable on every device and screen reader.

Mono CleanInput

Currency Input

Amount field with currency symbol prefix and an attached currency select; formats with thousands separators on blur, right-aligned mono digits.

Neo CorporateInput

File Upload

Receipt/document dropzone: dashed bordered area with upload icon, click-or-drag, file list with size, per-file size validation errors and remove buttons.

Neo CorporateInput

Input

Form field: label (with optional marker), bordered 40px input with leading/trailing adornments, blue focus ring, hint text or red error with aria-invalid.

Neo CorporateInput

Select Field

Labelled Radix Select styled as a bordered field: grouped options (e.g. GL accounts) with group headings, check on the selected item, portalled popover with data-da.

Neo CorporateInput

Chip Select

Multi-select as soft pill checkboxes: unselected sand pills, selected sage pills with a check that pops in; native checkboxes in a fieldset.

Organic SoftInput

Input

Soft filled text field: rounded sand-filled input that turns cream with a sage ring on focus, optional leading icon and trailing unit, hint or gentle clay error message.

Organic SoftInput

Target Slider

Reduction target picker: a thick rounded sage range (0–60%) with tick labels and a “science-aligned” marker, showing the resulting tonnes and a gentle verdict.

Organic SoftInput

Textarea

Soft note field: rounded sand textarea that auto-grows (field-sizing), with a live character counter that turns clay near the limit.

Organic SoftInput

Checkbox List

Round-checkbox to-do list built on native checkboxes: bouncy mint ticks, strike-through when done, meta line per item and an “x of y” counter with a progress bar.

Soft FlatInput

Day Picker

Week-strip date picker: prev/next week arrows and seven rounded day pills (weekday + number) with task-load dots (red when full); the selected day fills periwinkle.

Soft FlatInput

Input

Soft text field: rounded tinted well that turns white with a thick periwinkle ring on focus, label, optional leading icon and suffix, hint or red error message.

Soft FlatInput

Radio Cards

Native radio group rendered as big pastel cards (emoji, title, text); the chosen card lifts with a periwinkle ring and a filled radio dot.

Soft FlatInput