Search provides the ability to narrow down data using a specialized TextField.
| # | Required | Element | Description |
|---|---|---|---|
| 1 | Container | Wrapper that includes the field, label, and assistive text. | |
| 2 | No | Label | Describes what the Search covers. Accepts rich content such as icons or tooltips. |
| 3 | No | Icon | Leading icon that identifies the field as a search. Can be replaced or removed. |
| 4 | Field | Accepts user query. Can show a placeholder if empty. | |
| 5 | No | Assistive text | Displays description or error text to aid the user. |
Search narrows a large set of data based on user input. Use it when it would be faster for the user to filter by typing than scrolling or paging through a list.
Prefer a plain TextField when the value the user types is data to be saved rather than a query.
Search, Combobox, and Filters are three similar components that help the user narrow down data into digestible results. However, it's important to understand the difference between them as they are not interchangeable:
Search usually sits in a toolbar or page header, where a visible label competes with the controls around it. In those placements, we highly recommend providing an accessible label in place of a visible label. When outside of more compact layouts, a visible label is preferred.
Show the loading spinner while results are being fetched. Keep the field editable while it runs. Disabling the Search leaves the user unable to refine a slow query and dims the text they just typed.
Always show what the query returned. If there are no matches, use an EmptyState to describe the issue and offer a potential solution.
Try a shorter search term or check the spelling.
In adhering with Pluma's focus on flexibility, the Search component includes customization options beyond plain text. Customization is useful for adding richer label content or building custom assistive text.
Descriptions are assistive text that display below the field. They can accept rich content including links.
A description with an inline link directs users to additional resources.
Error messages are assistive text that display below the field. They accept rich content, allowing the inclusion of links or formatted text that better help users resolve the issue.
An error message with a link directs users to relevant documentation or support.
The label accepts rich content, allowing supplementary elements such as icons or tooltips alongside the label text.
A tooltip explains what the query covers without lengthening the label.
A magnifying glass icon leads the field by default and makes it recognizable as a search field without an explicit label. Replace it only when another icon better describes the scope or purpose of the search. Remove the icon when the Search component sits inside a menu or panel narrow enough that the icon crowds the text.
The search icon identifies the field at a glance and suits most placements.
Removing the icon gives the query more room in a narrow menu or panel.
Search is available in two sizes: medium and small. Small is the default and fits the toolbars and page headers where search usually sits. Use medium when the Search is the primary control on the page or would best match other form control sizes.
Small is the default and keeps the field compact in toolbars and filter rows.
Medium suits a Search that anchors a page or shares space with medium form controls.
Search has a max width of space-3200 (256px) so it remains compact next to other toolbar controls. The Search's width can be set to expand the full container size if required.
The default cap keeps the field from stretching across a toolbar.
Widening the field ties it to the full-width content it filters.
The Search has default input styling in its base resting state.
Border color updates on mouse hover to signal the field is interactive.
On keyboard focus, the field receives the standard 2px focus ring and the border color updates.
Active styles apply while the user is interacting with the field.
Disabled fields cannot be interacted with. Background and text color update to indicate the field is unavailable.
A spinner displays inside the field while results are being fetched.
The Search adopts critical styling to indicate there's an error. An error message displays below the field when set.
A clear button appears at the end of the field once it has a value and resets the field when activated.
The clear button resets the field and the results.
Assistive text displays below the Search and tells the user something about the query they're entering. Assistive text comes in different forms including descriptions and error text.
Use description text to name what the query matches or to explain syntax the field supports. Reach for a description when additional context is needed for the field. Short, complete sentences are preferred.
Errors on a Search describe a query the field is unable to run. Explain what the field can't handle and what to change. Keep messages direct and concise.
For information on how to handle no results, see Results.
Write clear, concise labels that describe what data is being searched.
Placeholders help the user complete a field by providing hints on what information it expects or how it should be formatted. Prefer using sentence case without a trailing ellipsis.