packages/react-components/react-search/library/docs/Spec.md
SearchBox is a text input field abstracting <input type="search" />.
In prior art, searchboxes are often integrated within an input or text component. These searchboxes often have a search icon that precedes the input and a clear button that follows the input. However, they lack support for additional content.
The v8 SearchBox component is implemented as a text input field that lacks a type attribute.
The v8 component supports:
The v8 component spans the entire width of its parent component. There are two visual variants of the v8 component: default and underlined. The v8 component can be disabled.
Documentation for v8 SearchBox
<SearchBox
ariaLabel="SearchBox"
placeholder="Search"
onSearch={newValue => console.log('value is ' + newValue)}
/>
Because v0 does not have a designated search component, search functionalities fall upon the Input component. The v0 Input component is implemented as a text input field with type="text". If the input is search, the input will include role="search".
The v0 component supports:
The v0 component has a fixed width that can be changed to span the length of its parent component. Visual variants of the v0 component can be controlled using props. The v0 component can be disabled.
<SearchBox
appearance="underline"
className="rootClass"
input={{ className: 'searchBoxClass' }}
id="searchBox1"
value="something"
onChange={(ev, data) => console.log(data.value)}
contentBefore={<SearchIcon />}
contentAfter={<MicIcon />}
dismiss={<ClearIcon />}
/>
Search supports the same appearance variants as Input, as follows:
outline (default): the field has a full outline, with a slightly darker underline on the bottomunderline: the field has an underline on the bottom onlyfilledDarker: the field has a gray background and no underline/outlinefilledLighter: the field has a white background and no underline/outline (for use on top of gray/colored backgrounds)SearchBox uses Input as its root element, makinginput the primary slot. Per the native element props/primary slot RFC, this means that most top-level props will go to input, but the top-level className and style will go to the actual root element.
The contentAfter and dismiss are bundled into one div and used as
Notes on the HTML rendering:
span rather than div prevents nesting errors if the Input is rendered inline within a <p>.contentBefore, contentAfter, and actual input elements are positioned inside it.\See MIGRATION.md
The input behavior is inherited from the native <input> element.
The component has the following interactive states:
Keyboard, cursor, touch, and screen reader interaction will be handled automatically by the internal <input>.
The dismiss button will appear when the component is in focus. When pressed, it will clear the value in the input. Note that this button is not in the tab order.
We don't implement enter to search, this would come from the consuming team.
Most interaction and screen reader behavior will be handled automatically by the internal <input type="search">.
<input> is visible and shows the placeholder or value text.id (associated with a label using htmlFor), aria-label, or aria-labelledby.root rather than the <input> itself (which is rendered without a border and only used to show the text), because the contentBefore, contentAfter, and dismiss slots need to visually appear to be within the input.role="search"