UI Patterns

Expandable searchStatusrelease

Show and hide inline search with a button.

Guidance

Use this pattern for a search form that expands and collapses in the document flow. In contrast modal search captures focus, takes over the whole screen and prevents interaction with the rest of the page. The expandable pattern does not trap tab in the same way.

Example

Open in a new tab

Dependencies and installation

PackageInstallation
@stormid/toggle
npm i -S @stormid/toggle

Code

<div class="expandable-search__container"><button class="expandable-search__btn js-expandable-search__btn" aria-label="Show or hide site search"><svg class="expandable-search__btn-icon" focusable="false" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#fff"><path d="M0 0h24v24H0z" fill="none"></path><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path></svg></button><div class="expandable-search js-expandable-search" id="expandable-search" data-toggle="js-expandable-search__btn"><form class="expandable-search__form" action="#" role="search"><label class="expandable-search__label" for="q">Input your search term</label><input class="expandable-search__input" type="search" id="q" name="q"/><button class="expandable-search__submit">search</button></form></div></div>
import toggle from '@stormid/toggle';

toggle('.js-expandable-search');

Acceptance criteria

The following is a list of example acceptance criteria to test against when using this pattern. These critera should test that the specific markup requirements are met, and that the search behaves visually and functionally as expected.

For validation in developer tools / web inspector

For visual validation

For functional validation

References