This component is still in Beta. Please reach out to Design System team before using it.
This component is deprecated! Please use the new Search field instead.
Old component won’t get updates unless extraordinary circumstances require otherwise → reach out to our PO to discuss it.
New component should always be used unless extraordinary circumstances require otherwise → reach out to our PO to discuss it.
If you are looking to migrate this component and require help, reach out to the #ask-design-system Slack channel.
<!-- for demo only -->
<tk-highlight id="exampleSearchOutput"
> </tk-highlight>
<tk-search
id="exampleSearch"
placeholder="Search"
full-width="false"
> <tk-search-overlay id="exampleSearchOverlay" slot="search-overlay">
<tk-search-overlay-section>
<span slot="header">Recent Searches</span>
<tk-button
alignment="trailing"
slot="header-action"
size="compact"
type="ghost"
id="clearRecentBtn"
>
Clear recent
</tk-button>
<tk-search-overlay-item icon="search">
analytics
</tk-search-overlay-item>
</tk-search-overlay-section>
<tk-search-overlay-section>
<span slot="header">Tests</span>
<tk-search-overlay-item url="https://www.usertesting.com/" icon="record">
New <strong>concept</strong> workflow
</tk-search-overlay-item>
<tk-search-overlay-item url="https://www.usertesting.com/" icon="unmoderated">
Updated <strong>concept</strong>
</tk-search-overlay-item>
<tk-search-overlay-item url="https://www.usertesting.com/" icon="unmoderated">
[WorkspaceName] > Updated <strong>concept</strong> > Note: third concept was preferred
</tk-search-overlay-item>
<tk-search-overlay-item url="https://www.usertesting.com/" icon="record">
UX Research - Dashboard <strong>Concept</strong>
</tk-search-overlay-item>
<tk-search-overlay-item url="https://www.usertesting.com/" icon="unmoderated">
<strong>Concept</strong> Information Architecture
</tk-search-overlay-item>
</tk-search-overlay-section>
<tk-search-overlay-section>
<span slot="header">Drafts</span>
<tk-search-overlay-item url="https://www.usertesting.com/" icon="document">
<strong>Concept</strong> validation
</tk-search-overlay-item>
<tk-search-overlay-item url="https://www.usertesting.com/" icon="document">
Customer environment and <strong>concept</strong>s
</tk-search-overlay-item>
</tk-search-overlay-section>
<tk-search-overlay-section>
<span slot="header">Highlight reels</span>
<tk-search-overlay-item url="https://www.usertesting.com/" icon="highlight-reel">
New customers like the report <strong>concept</strong>
</tk-search-overlay-item>
<tk-search-overlay-item url="https://www.usertesting.com/" icon="highlight-reel">
Customer mental models & <strong>concept</strong>s aren’t consistent across personas
</tk-search-overlay-item>
</tk-search-overlay-section>
</tk-search-overlay>
</tk-search>
<script>
const displayInputSearchEventChange = (outputElement, amount) => {
outputElement.innerText = `📣 valueChanged emitted: ${amount}`;
}
const clearRecent = () => {
const recentSearches = document.querySelector('tk-search-overlay-section:nth-child(1)');
if (recentSearches) {
recentSearches.remove();
}
}
const hideSearchOverlay = () => {
exampleSearchOverlay.removeAttribute('is-visible');
}
exampleSearch.addEventListener('valueChanged', ($event) => {
displayInputSearchEventChange(exampleSearchOutput, $event.detail);
if ($event.detail === null || !$event.detail.length) {
hideSearchOverlay();
}
});
exampleSearch.addEventListener('submitEvent', ($event) => {
exampleSearch.setAttribute("full-width", true);
});
exampleSearch.addEventListener('expanded', ($event) => exampleSearchOverlay.setAttribute('is-visible', 'true'));
exampleSearch.addEventListener('close', ($event) => hideSearchOverlay());
clearRecentBtn.addEventListener('click', ($event) => clearRecent());
</script>The search input component is a control that allows the user to quickly look for content within our application.