# Search

Compact nav search affordance — a button styled as an input with a ⌘K hint that opens the command palette.

[All components](https://rickylabs.github.io/netscript/design-system/components/) · [Theme builder](https://rickylabs.github.io/netscript/create/) · [Implementation source](https://github.com/rickylabs/netscript/blob/main/packages/fresh-ui/registry/components/ui/search.tsx)

## Live preview

[Open live search preview](https://rickylabs.github.io/netscript/assets/fresh-ui/preview/?component=search&theme=studio-utility)

## Install

```bash
netscript ui:add search
```

## Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

```tsx
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 |  |

```typescript
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](https://www.w3.org/WAI/ARIA/apg/patterns/button/)

- 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.
