Skip to content

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-clean/ui/search-input
Open ↗

Source

"use client";

import { useId, useMemo, useState } from "react";
import { Search } from "lucide-react";
import { cn } from "@/lib/utils";

export interface SearchInputProps {
  label?: string;
  items?: { title: string; kind: string; href: string }[];
  /** Initial query. */
  defaultQuery?: string;
  className?: string;
}

const DEFAULT_ITEMS = [
  { title: "Oslo Opera — Identity", kind: "Project", href: "#p1" },
  { title: "Kiln Coffee — Packaging", kind: "Project", href: "#p2" },
  { title: "Atlas", kind: "Template", href: "#t1" },
  { title: "Custom domains", kind: "Help", href: "#h1" },
  { title: "Typography settings", kind: "Help", href: "#h2" },
];

/** 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. */
export function SearchInput({ label = "Search", items = DEFAULT_ITEMS, defaultQuery = "ra", className }: SearchInputProps) {
  const id = useId();
  const [q, setQ] = useState(defaultQuery);
  const results = useMemo(() => (q.trim() ? items.filter((i) => i.title.toLowerCase().includes(q.trim().toLowerCase())) : []), [items, q]);
  const mark = (t: string) => {
    const i = t.toLowerCase().indexOf(q.trim().toLowerCase());
    if (i < 0 || !q.trim()) return t;
    return (
      <>
        {t.slice(0, i)}
        <mark className="bg-da-accent/30 text-inherit">{t.slice(i, i + q.trim().length)}</mark>
        {t.slice(i + q.trim().length)}
      </>
    );
  };
  return (
    <div className={cn("w-full max-w-md", className)}>
      <label htmlFor={id} className="sr-only">
        {label}
      </label>
      <div className="flex h-11 items-center gap-3 border border-da-border px-3 focus-within:border-da-border-strong">
        <Search aria-hidden className="size-4 text-da-muted-fg" />
        <input
          id={id}
          type="search"
          value={q}
          onChange={(e) => setQ(e.target.value)}
          placeholder="Projects, templates, help…"
          aria-controls={`${id}-r`}
          className="min-w-0 flex-1 bg-transparent outline-none placeholder:text-da-muted-fg"
        />
        <kbd className="rounded-da-sm border border-da-border px-1 font-da-mono text-[11px] text-da-muted-fg">⌘K</kbd>
      </div>
      <div id={`${id}-r`} aria-live="polite">
        {q.trim() &&
          (results.length ? (
            <ul className="border-x border-b border-da-border">
              {results.map((r) => (
                <li key={r.href} className="border-b border-da-border last:border-0">
                  <a href={r.href} className="da-focus flex items-center justify-between gap-4 px-3 py-2.5 text-[15px] hover:bg-da-surface-2">
                    <span>{mark(r.title)}</span>
                    <span className="font-da-mono text-[10px] tracking-da-label text-da-muted-fg uppercase">{r.kind}</span>
                  </a>
                </li>
              ))}
            </ul>
          ) : (
            <p className="border-x border-b border-da-border px-3 py-4 text-sm text-da-muted-fg">No results for “{q}”.</p>
          ))}
      </div>
    </div>
  );
}

export default SearchInput;

modules/mono-clean/ui/search-input/index.tsx

Props

PropTypeDefaultDescription
labelstring—Label.
items{ title: string; kind: string; href: string }[]—Content items (see the exported types).
defaultQuerystring—Initial query.
classNamestring—Extra classes on the root.

Other input variants in Mono Clean

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

Combobox

Autocomplete select: a glass pill input that filters a frosted listbox as you type, with arrow-key highlight, Enter to choose, Escape to close, hints and a check on the selection.

GlassInput

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.

GlassInput

Range Slider

Glass slider on Radix Slider: frosted track, primary→accent range, glowing gradient thumbs with value bubbles on hover/focus and tick labels; single value or range.

GlassInput

Tag Input

Glass chip input: type and press Enter or comma to add gradient chips, Backspace removes the last, × removes one; quick-add suggestion chips and a max counter.

GlassInput

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

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