Taiga UI 5 is out!

SearchBar ADDON-MOBILE

GitHub

On this page

TuiSearchBar is a mobile search field. Put tuiSearchBar on any element — semantically that is <search> — project a native <input tuiSearchBar> into it and a <button tuiButtonX> next to it. The searchbar only lays them out per platform: on iOS the button sits to the right of the field, on Android it moves inside the field on the leading side and turns into a back arrow.

Inline iOS

    
      
    
    
      <search tuiSearchBar>
    <input
        placeholder="Search"
        tuiSearchBar
    />
</search>

    

Android

No form here, so the cancel button clears the field through a FormControl
    
      
    
    
      <search tuiSearchBar>
    <input
        placeholder="Search"
        tuiSearchBar
        [formControl]="query"
    />
    <button
        tuiButtonX
        (click)="query.reset()"
    >
        Cancel
    </button>
</search>

    

iOS floating

An active field on iOS is floating : liquid glass with a round cancel button. The bar sits on a <form> , so clearing and Enter work on their own
    
      
    
    
      <search>
    <form
        appearance="floating"
        tuiSearchBar
        (ngSubmit)="onSubmit()"
    >
        <input
            name="query"
            placeholder="Search"
            tuiSearchBar
            [(ngModel)]="query"
        />
        <button
            tuiButtonX
            type="reset"
        >
            Cancel
        </button>
    </form>
</search>

    
    
      :host {
    display: block;
    box-sizing: border-box;
    inline-size: 20rem;
    padding: 1.5rem 1rem;
    overflow-x: hidden;
}

    

App bar

Pinned along with the app bar, the field is floating from the start and keeps that look while the content scrolls under it. Pinning is up to you, the search bar only takes care of the look. Once the field becomes active, it takes the place of the app bar
Taiga UI
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
    
      
    
    
      <header class="header">
    @if (!active()) {
        <tui-app-bar>
            <button
                title="Back"
                tuiAppBarBack
                tuiSlot="start"
                type="button"
            ></button>
            Taiga UI
        </tui-app-bar>
    }

    <search>
        <form
            appearance="floating"
            tuiSearchBar
            (tuiActiveZoneChange)="active.set($event)"
        >
            <input
                placeholder="Search"
                tuiSearchBar
            />
            <button
                tuiButtonX
                type="reset"
            >
                Cancel
            </button>
        </form>
    </search>
</header>

@for (_ of '-'.repeat(12); track $index) {
    <div tuiCell>
        <div
            appearance="secondary"
            tuiAvatar="@tui.heart"
        ></div>
        <div tuiTitle>
            Title
            <div tuiSubtitle>Description</div>
        </div>
    </div>
}

    
    
      :host {
    display: block;
    max-block-size: 20rem;
    inline-size: 20rem;
    overscroll-behavior: none;
    overflow-x: hidden;
}

.header {
    position: sticky;
    z-index: 1;
    inset-block-start: 0;
    overflow: hidden;
    margin-block-end: -2rem;
    padding-block-end: 2rem;
}

search {
    padding: 0.75rem 1rem;
}

    

Sticky

Under a large heading the field starts inline and turns floating once the heading scrolls away — here the switch is driven by an IntersectionObserver watching the heading

Search

Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
Title
Description
    
      
    
    
      <h2
    class="title"
    (waIntersectionObservee)="floating.set(!$event[0]?.isIntersecting)"
>
    Search
</h2>

<search>
    <form
        tuiSearchBar
        [appearance]="floating() ? 'floating' : 'neutral'"
    >
        <input
            placeholder="Search"
            tuiSearchBar
        />
        <button
            tuiButtonX
            type="reset"
        >
            Cancel
        </button>
    </form>
</search>

@for (_ of '-'.repeat(12); track $index) {
    <div tuiCell>
        <div
            appearance="secondary"
            tuiAvatar="@tui.heart"
        ></div>
        <div tuiTitle>
            Title
            <div tuiSubtitle>Description</div>
        </div>
    </div>
}

    
    
      :host {
    display: block;
    max-block-size: 20rem;
    inline-size: 20rem;
    overflow: auto;
    overscroll-behavior: none;
}

.title {
    margin: 0.5rem 0;
    font: var(--tui-typography-heading-h4);
    font-weight: bold;
}

search {
    position: sticky;
    z-index: 1;
    inset-block-start: 0;
    padding: 0.75rem 1rem;
}