Input Button
A button that looks like a text field, to open a search, a command palette or a picker. In the look of the app's style's input.
Usage
import { Component, ViewEncapsulation } from '@angular/core';import { ScInputButton, ScKbd } from '@semantic-components/ui';import { SiSearchIcon } from '@semantic-icons/lucide-icons';
@Component({ selector: 'app-input-button-usage-demo', imports: [ScInputButton, ScKbd, SiSearchIcon], template: ` <button scInputButton data-placeholder class="max-w-sm"> <svg siSearchIcon></svg> <span class="flex-1">Search...</span> <kbd scKbd>⌘<span class="sr-only"> Command</span>J</kbd> </button> `, host: { class: 'flex w-full justify-center' }, encapsulation: ViewEncapsulation.None,})export class InputButtonUsageDemo {}Anatomy
A directive on your button; the icon, the text and the shortcut (scKbd) are yours.
import { ScInputButton } from '@semantic-components/ui';<button scInputButton data-placeholder> <svg …></svg> <span class="flex-1">…</span> <kbd scKbd>…</kbd></button>Accessibility
- A button, not a field: read as one, pressed with Enter or Space. What it opens (a dialog, a palette) does the searching.
- Its name is its text; icon only, give it sr-only text. Name a shortcut's symbols too (⌘: "Command").
Examples
Full width
import { Component, ViewEncapsulation } from '@angular/core';import { ScInputButton, ScKbd } from '@semantic-components/ui';import { SiSearchIcon } from '@semantic-icons/lucide-icons';
/** As wide as its place: a search across a header. */@Component({ selector: 'app-full-width-input-button-demo', imports: [ScInputButton, ScKbd, SiSearchIcon], template: ` <div class="w-full max-w-2xl">Icon only
import { Component, ViewEncapsulation } from '@angular/core';import { ScInputButton } from '@semantic-components/ui';import { SiSearchIcon } from '@semantic-icons/lucide-icons';
/** Its icon alone (a collapsed sidebar): named in sr-only text. */@Component({ selector: 'app-icon-input-button-demo', imports: [ScInputButton, SiSearchIcon], template: ` <button scInputButton data-placeholder class="size-8 justify-center p-0">RTL
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import { ScInputButton, ScKbd } from '@semantic-components/ui';import { SiSearchIcon } from '@semantic-icons/lucide-icons';
/** In a right-to-left page: the icon at the right, the shortcut at the left. */@Component({ selector: 'app-rtl-input-button-demo', imports: [Dir, ScInputButton, ScKbd, SiSearchIcon], template: `API reference
Each part takes class, merged over the style (cn: a later class wins).
| Part | Selector | Description |
|---|---|---|
ScInputButton | button[scInputButton] | A button in the style's input look: its text muted while data-placeholder (yours on a search; a picker's trigger sets it while empty), a long text cut, its icon sized; type="button". |