# Search field

> Find words in the screenplay. Results read like the script: scene numbers in both margins, the heading in Courier, the match marked in the line.

Source: https://kwark.space/designSystem/components/search-field

## Usage

### What it is
Search finds words where a filmmaker keeps them: the screenplay, a scene, the notes. It is the library’s 44px search box (`.home-search`) grown into a find bar: a count (*2 of 5*), previous and next, clear, and a scope. Results are set like the script they come from: the **scene number in both margins**, the heading in Courier Prime, and the line that matched with the word marked in a soft `--k-accent-soft` wash, the colour of a highlighter on paper.

### When to use
- Finding a word, a name or a prop across the screenplay (*cardigan*, *Mira*), within one scene, or in notes.
- Filtering a long list in place: the library, the cast, the breakdown (without the results panel).

### When not to
- Picking one value for a field: [Combobox](https://kwark.space/designSystem/components/combobox.md).
- Jumping to a command or a module: the [Command palette](https://kwark.space/designSystem/components/command-palette.md).
- Replacing text in the script: that is the editor’s Find and replace, which shows each change as a [Revision mark](https://kwark.space/designSystem/components/revision-mark.md).

### Behaviour
- Results update as you type, after 150ms of rest. The query is kept when you open a result and come back.
- Changing the scope keeps the query and says how many matches the new scope has, including *No matches*.
- Enter goes to the next match; Shift + Enter to the previous. In the editor the page scrolls to the match and marks it.
- No results is not a dead end: it names what was searched and where, and offers the next place to look.
- Search never edits or judges the script. It finds and carries the reader there.

**Do:** *2 of 5*, with *12 · INT. EDIT SUITE – NIGHT · 12* and the line where *cardigan* is marked.

**Don't:** A list of page numbers with no headings, or a toast that says *No results* and clears the query.

## Style

### Anatomy

1. **Box**: 44px, 1px `--k-line`, 6px corners, the input ground. 16px search glyph, 14px text. Focus: `--k-accent-soft` edge and a 2px ring.
2. **Count**: 500 12px tabular, `--k-text-2`; *No matches* in `--k-danger`.
3. **Controls**: clear, then a 1px divider, then previous and next: 32px icon buttons (44 on touch), 16px glyphs.
4. **Empty**: placeholder *Search the screenplay* and the shortcut as a keycap.
5. **Scope**: a [Segmented control](https://kwark.space/designSystem/components/segmented-control.md) under the box: *Whole script*, *Scene 12*, *Notes*.
6. **Results**: a 10px-corner panel. Each hit is a grid: number (3ch), heading, number (3ch) in Courier Prime 700 12px; the matched line under the heading in 12px Poppins. Current hit: `--k-raise` and a 2px ink line on the left.
7. **Match mark**: `--k-accent-soft` at 45% behind the word, 2px corners, the text colour unchanged.

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-surface` | #ffffff | #1a1a1a |
| `--k-bg` | #f8fafc | #191919 |
| `--k-raise` | #f1f5f9 | #252525 |
| `--k-line` | #e2e8f0 | rgba(255, 255, 255, .1) |
| `--k-line-strong` | var(--k-text-2) | var(--k-text-2) |
| `--k-text` | #0f172a | #e3e3e3 |
| `--k-text-2` | #5b6779 | #9ca3af |
| `--k-accent-soft` | #e8b58b | #e8b58b |
| `--k-danger` | #b4382c | #e0685c |
| `--k-font-screenplay` | 'Courier Prime', 'Courier New', monospace |  |
| `--k-tap` | 44px |  |
| `--k-radius-control` | 6px |  |
| `--k-radius-card` | 10px |  |

## Code

### React

Use the HTML below with `kwark.css`. The example shows the markup and styling. Supply any application behavior described on this page.

### HTML and CSS

Works anywhere with `kwark.css`.

```html
<div class="kw-find">
  <div class="kw-find__box"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg><input type="search" value="cardigan" aria-label="Search the screenplay"><span class="kw-find__count" aria-live="polite">2 of 5</span><button class="kw-ibtn" type="button" aria-label="Clear search"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"/></svg></button><span class="kw-find__sep" aria-hidden="true"></span><button class="kw-ibtn" type="button" aria-label="Previous match"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m18 15-6-6-6 6"/></svg></button><button class="kw-ibtn" type="button" aria-label="Next match"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></button></div>
  <div class="kw-segment" role="radiogroup" aria-label="Search in"><button type="button" role="radio" aria-checked="true">Whole script</button><button type="button" role="radio" aria-checked="false" tabindex="-1">Scene 12</button><button type="button" role="radio" aria-checked="false" tabindex="-1">Notes</button></div>
  <ul class="kw-find__results" role="listbox" aria-label="Matches in the screenplay">
    <li><a class="kw-find__hit" href="#scene-9" role="option" aria-selected="false"><span class="kw-find__no">9</span><span class="kw-find__slug">INT. MIRA’S FLAT – MORNING</span><span class="kw-find__no">9</span><p class="kw-find__snip">She pulls on the grey <mark>cardigan</mark>, sleeves pushed up.</p></a></li>
    <li><a class="kw-find__hit" href="#scene-12" role="option" aria-selected="true"><span class="kw-find__no">12</span><span class="kw-find__slug">INT. EDIT SUITE – NIGHT</span><span class="kw-find__no">12</span><p class="kw-find__snip">Mira wipes the screen with the cuff of her <mark>cardigan</mark>.</p></a></li>
    <li><a class="kw-find__hit" href="#scene-14" role="option" aria-selected="false"><span class="kw-find__no">14</span><span class="kw-find__slug">EXT. STREET OUTSIDE THE LAB – NIGHT</span><span class="kw-find__no">14</span><p class="kw-find__snip">Rain darkens the <mark>cardigan</mark> to charcoal.</p></a></li>
  </ul>
</div>
<div class="kw-find" style="align-content:start">
  <div class="kw-find__box"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg><input type="search" placeholder="Search the screenplay" aria-label="Search the screenplay"><kbd>⌘F</kbd></div>
  <div class="kw-find__box"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg><input type="search" value="Nana" aria-label="Search the screenplay"><span class="kw-find__count kw-find__count--none" aria-live="polite">No matches</span><button class="kw-ibtn" type="button" aria-label="Clear search"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"/></svg></button></div>
  <p class="kw-find__empty">No scene mentions <b>“Nana”</b> in the whole script. Her name may be in the notes: <button class="kw-linkbtn" type="button">Search notes</button></p>
</div>
```

## Accessibility

### Keyboard
| Key | Does |
|---|---|
| ⌘F / Ctrl+F | Focuses the search (in the editor). |
| Enter / Shift + Enter | Next / previous match. |
| Down / Up | Moves through the results list. |
| Escape | Clears the query; a second Escape closes the find bar and returns focus. |

### Roles and names
- `<input type="search">` named *Search the screenplay* (the scope’s name, not *Search*).
- The count is a polite live region, so *2 of 5* and *No matches* are announced without moving focus.
- Previous, next and clear are icon buttons with full names.
- The results are a `listbox` of options; each option’s name reads naturally: *Scene 12, INT. EDIT SUITE – NIGHT, Mira wipes the screen with the cuff of her cardigan*.
- The `<mark>` is also exposed as *highlighted* by screen readers that support it; never rely on its colour alone, the count says where you are.

## For agents

### Rules

- **Must** keep the query when the scope changes or a result is opened.
- **Always** show the match count and offer next and previous.
- **Must** show scene numbers in both margins and the heading in Courier Prime in screenplay results.
- **Never** leave a no-results state without saying what was searched and where to look next.
- **Never** edit, rank or judge the script from search; it only finds and carries the reader to the words.

### AI readiness test

**Task:** Add find to the screenplay editor’s toolbar.

**Give the agent:** Search field, Segmented control, Screenplay page.

**Constraint:** Scope can be the whole script, the current scene or notes.

**A reliable answer:**
- 44px search box named Search the screenplay
- Count announced politely
- Next and previous
- Results with scene numbers both sides
- No-results names the scope and offers Notes
