An official website of the United States government
Here’s how you know
Official websites use .gov A
.gov website belongs to an official government
organization in the United States.
Secure .gov websites use HTTPS A
lock (
) or https:// means you’ve safely connected to
the .gov website. Share sensitive information only on official,
secure websites.
Search allows users to search for specific content if they know what search terms to use or can’t find desired content in the main navigation
Passed WCAG 2.1 AA
Default
Big variant
Small variant
Spanish default variant
Spanish big variant
Spanish small variant
Guidance
When to use the search component
Use site search. There will always be users who would benefit from being able to search your site.
When to consider something else
Very small sites. On single-page or very small sites, you may be able to get away without a search bar.
Usability guidance
Make the input at least 27 characters wide. Allow the search component to be as wide as possible, but a minimum of 27 characters wide. This allows users to enter multiple search terms and still be able to see all of them. The more users can see their search terms, the easier it is to review, verify, and submit their search query. Romance languages are about 20% longer than English, so account for text swell on multilingual websites.
The magnifying glass icon is effective. The magnifying glass has been shown to be almost universally recognized by users as an indicator of search, and doesn’t need to be visually paired with the word “Search” as long as it remains for screen readers.
Search terms should persist into search results. When displaying the search results, preload the search bar content with the original search terms.
Use a full search box on the home page. On a site’s home page the search function should appear as a search box instead of a link so users can locate it easily.
Don’t offer advanced search as the default. The majority of people will do a simple search with one or two search terms. If advanced search is offered, it increases the likelihood of mistakes.
Use a label even if it’s visually hidden. The form field should include a label for screen reader users.
The search button should be a submit button. This reduces the number of keystrokes required to use the form.
Accessibility guidance
Test the search component in your own project.
USWDS tested the search component for accessibility. You should test your implementation, too.
Include the word “Search” in the button. Always include the word “search” inside the <button> element for screen readers. You can visually hide this text using the CSS class usa-sr-only or Sass mixin @include sr-only.
Using the search component
Search settings
Variable
Description
$theme-search-font-family
Font family of the search.
$theme-search-min-width
Min-width of the search input.
Search variants
Variant
Description
.usa-search--big
Search component with increased padding and font-size.
.usa-search--small
A compact variation of the search. Uses a magnifying glass icon for the submit button.
Accessibility test status
The USWDS team did 22 tests based on WCAG 2.1 AA success criteria.
Breaking
Improved resilience of icon-only functionality.
Updated to add a text equivalent if the image path is broken and does not load.
More information:
uswds#4274