Back to Fluentui

SearchBoxBestPractices

packages/react-components/react-search/stories/src/SearchBox/SearchBoxBestPractices.md

4.40.2-hotfix21.0 KB
Original Source

Best practices

Do

  • Consider wrapping SearchBox in a role="search" container for top-level site or app search fields. This role exposes the search field as a landmark, and makes it easier to find for screen reader users. It should not be used unless the SearchBox is the primary search area for the entire site or app.

  • Consider using SearchBox with underline or outline appearances. When the contrast ratio against the immediate surrounding color is less than 3:1, consider using underline or outline styles which has a bottom border stroke. But please ensure the color of bottom border stroke has a sufficient contrast which is greater than 3 to 1 against the immediate surrounding.

Don't

  • Don't place SearchBox on a surface which doesn't have a sufficient contrast. The colors adjacent to the input should have a sufficient contrast. Particularly, the color of input with filled darker and lighter styles needs to provide greater than 3 to 1 contrast ratio against the immediate surrounding color to pass accessibility requirements.