Search
Compact nav search affordance — a button styled as an input with a ⌘K hint that opens the command palette.
All components · Theme builder · Implementation source
Live preview
Install
netscript ui:add searchUsage and examples
The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.
import { useState } from 'preact/hooks';
import { Search } from '@app/components/ui/search.tsx';
export function Example() {
const [value, setValue] = useState('standard');
const [open, setOpen] = useState(false);
const [notice, report] = useState('');
return (<><div><Search aria-label="Search orders" placeholder="Search orders…" onOpen={()=>report("Search opened")} /></div><p role="status">{notice}</p></>);
}Props
Generated from native deno doc --json --private over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.
| Owner | Prop | Type | Optional | Description |
|---|---|---|---|---|
SearchProps | placeholder | string | Yes | Placeholder/label copy shown inside the field. |
SearchProps | shortcut | string | Yes | Keyboard hint glyphs, e.g. `⌘K`. Hidden when empty. |
SearchProps | onOpen | () => void | Yes | Invoked when the field is activated (opens the palette). |
SearchProps | class | string | Yes |
SearchProps extends Omit<JSX.HTMLAttributes<HTMLButtonElement>, "class" | "onClick">Keyboard
| Key | Action |
|---|---|
Enter | Activate |
Space | Activate button; links use native Enter |
Tokens
Semantic contract roles: border/default, border/hover, radius/input, surface/card, text/fg, text/muted.
CSS custom properties referenced directly: --ns-border, --ns-border-control, --ns-border-hover, --ns-card, --ns-control-height, --ns-ease-fast, --ns-focus-ring-offset, --ns-focus-ring-width, --ns-font-mono, --ns-font-sans, --ns-input-border, --ns-leading-snug, --ns-muted, --ns-muted-fg, --ns-radius-badge, --ns-radius-input, --ns-radius-md, --ns-radius-sm, --ns-ring, --ns-space-0-5, --ns-space-1-5, --ns-space-2, --ns-space-3, --ns-surface, --ns-text-2xs, --ns-text-base, --ns-text-body, --ns-text-caption, --ns-text-sm.
Contract and compatibility
Accessibility pattern: WAI-ARIA guidance
- Native DOM attributes pass through where the implementation accepts them.
Design contract values marked planned are not implementation props. The props above describe what ships today.