Skip to main content

Components

Search

Search allows users to quickly find relevant content on a website or in an application. The component consists of a search field, with or without a search button.

Usage

Examples

Variants

Based on how sub-components, and the structure of the HTML, you can change how Search is displayed.

With Label

If you want a label on the search field, you need to add a Label component that you connect with Search.Input. In the example, we have used Field to get a connection between Label and Search.Input.

<form>

HTML

You use the class name ds-search on a wrapper element around <input>. If you want a "clear" button, attach a <button> with type="reset"

It is important that you add an empty placeholder to <input> if you have a "clear" button

CSS variables and data attributes

CSS Variables
NameValue
--dsc-search-padding-inlinevar(--ds-size-2)
--dsc-search-clear-paddingvar(--ds-size-1)
--dsc-search-clear-sizevar(--ds-size-9)
--dsc-search-clear-icon-urlurl("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath fill='currentColor' d='M6.53 5.47a.75.75 0 0 0-1.06 1.06L10.94 12l-5.47 5.47a.75.75 0 1 0 1.06 1.06L12 13.06l5.47 5.47a.75.75 0 1 0 1.06-1.06L13.06 12l5.47-5.47a.75.75 0 0 0-1.06-1.06L12 10.94z'/%3E%3C/svg%3E")
--dsc-search-magnifying-icon-urlurl("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M10.5 3.25a7.25 7.25 0 1 0 4.57 12.88l5.41 5.41a.75.75 0 1 0 1.06-1.06l-5.41-5.41A7.25 7.25 0 0 0 10.5 3.25M4.75 10.5a5.75 5.75 0 1 1 11.5 0 5.75 5.75 0 0 1-11.5 0'/%3E%3C/svg%3E")
--dsc-search-magnifying-icon-sizevar(--ds-size-7)
--dsc-button-sizevar(--dsc-search-clear-size)

No relevant data attributes found.

Edit this page on github.com (opens in a new tab)