For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /dolan/search-field.md.

Search Field

A search field with a magnifier, a button that clears it and an optional Cancel. It's a Liquid Glass capsule on iOS 26, and can sit in the dock to search from the bottom of the screen, as iPhone apps do.

Installation

npx @blotch/dolan add search-field
import { UiSearchField } from '../components/ui/search-field';
Tip

This also adds Glass, which draws the field on iOS 26, and Icon, whose icons it draws.

Usage

src/app/app.ts
import { Component, signal } from '@angular/core';
import { UiSearchField } from '../components/ui/search-field';

@Component({
  selector: 'app-root',
  imports: [UiSearchField],
  template: `
    <ui-search-field
      placeholder="Songs and artists"
      cancelable
      [(value)]="query"
      (submitted)="search($event)"
    />
  `,
})
export class App {
  protected readonly query = signal('');

  protected search(text: string): void {
    // …
  }
}
  • [(value)] follows every keystroke, and setting the signal from code updates the field.
  • The keyboard's return key reads Search, and pressing it emits submitted with the text and closes the keyboard.
  • A clear button shows while there's text. It empties the field and keeps the keyboard up, as UIKit's does.
  • cancelable adds a Cancel that shows while the field is in use (focused, or holding text). It clears the field, closes the keyboard and emits canceled.
  • A field the keyboard would cover rises above it while it's focused (see The keyboard).

What each platform draws

PlatformWhat you get
iOS 26 and laterA 48pt Liquid Glass capsule. Cancel is a glass circle with an x that grows out of the field's end, which shrinks to make room.
iOS 15 to 25UISearchBar's field: a 36pt rounded rectangle on a gray fill, with a Cancel that slides in beside it.
AndroidMaterial 3's search bar: a 56dp capsule on a tonal surface. While it's in use, its search icon turns into a back arrow that cancels.
Android, with provideGlass()The glass capsule, drawn with Android's blur.
Web previewThe glass capsule, drawn with WebGL.

Glass belongs to the controls that float over your content. On iOS 26, put the field where it floats: at the top of a screen over its content, or in the dock.

Signal Forms

UiSearchField implements Angular's FormValueControl, so it works with the [formField] directive of Signal Forms (see Forms):

<ui-search-field [formField]="filters.query" />

Focus from code

focus() gives the field the keyboard, and blur() takes it away. hasFocus() says whether it has it:

readonly field = viewChild.required(UiSearchField);

openSearch(): void {
  this.field().focus();
}

The keyboard

Lynx doesn't move a field the keyboard covers, so the field does it: when the keyboard shows, it measures where it is on screen and rises above the keyboard by however much it would be covered, and settles when the keyboard closes. A field at the top of the screen stays where it is. In the dock, the whole dock rises with it.

It reads the keyboard's height from its <input>'s keyboardheightchange event, which iOS measures from the bottom of the window and Android from the bottom of the Lynx view. On Android, an app whose window already shrinks above the keyboard, as the one ng build --platform android makes does, reports nothing to rise by. See Forms for the keyboard elsewhere.

Dark mode

The icons draw with the light theme's colors until you say otherwise. If your app switches to dark mode, set the color scheme with provideIconTheme().

API

UiSearchField

InputTypeDefaultDescription
valuestring''The text. Two-way with [(value)].
placeholderstring'Search'What the field searches, shown while it's empty.
cancelablebooleanfalseShows a Cancel while the field is in use.
cancelLabelstring'Cancel'The Cancel's label, which screen readers say.
clearLabelstring'Clear text'What screen readers say for the clear button.
disabledbooleanfalseDims the field and ignores typing.
classstring''Extra Tailwind classes for the field, such as class="mx-4".
OutputTypeDescription
valueChangestringEmits the text as it changes.
submittedstringEmits the text when the keyboard's Search key is pressed.
canceledvoidEmits after Cancel clears the field and closes the keyboard.
focusedvoidEmits when the field gets the keyboard's focus.
blurredvoidEmits when it loses it.
PropertyTypeDescription
hasFocusSignal<boolean>Whether the field has the keyboard's focus.
keyboardHeightSignal<number>The keyboard's height in px while the field has focus.
designSignal<'glass' | 'frosted' | 'material'>The platform's design (see Glass).
focus()methodGives the field the keyboard's focus.
blur()methodTakes it away.
clear()methodEmpties the field.
cancel()methodWhat Cancel does.

Accessibility

  • The text box is a search field to screen readers (the search trait on iOS), named by its placeholder.
  • The clear button and Cancel are buttons, named by clearLabel and cancelLabel. Material's back arrow is the Cancel.
  • Reduce Motion: Cancel appears and the field rises above the keyboard at once, without growing or sliding.
  • Increase Contrast draws the glass field's magnifier and placeholder at full strength. Reduce Transparency is handled by the glass.
  • Dock: search from the bottom of the screen, as iOS 26 does
  • Input: a text field with a label, helper text and error message
  • Glass: the glass the field is drawn with
  • Forms: forms and the on-screen keyboard
  • <input>: the element underneath