Skip to main content

Modal Search

Modal Search overlays a complete Glean search experience on your existing page. Attach it to any search input you already have — when the input is clicked, a modal opens with autocomplete, suggestions, and full results.

portal.internal/engineering
Engineering PortalServicesRunbooksOn-call

Illustrative previewRendered with sample data — in your app, this component renders live against your organization's Glean instance.

Install the SDK

npm install @gleanwork/web-sdk

Attach to your search input

Point the attach method at a focusable element — such as the search input your page already renders — and the SDK handles all user interaction from there:

import { attach } from '@gleanwork/web-sdk';

attach(document.getElementById('search-box'), {
backend: 'https://{your}-be.glean.com/',
});

Options

The most commonly used ModalSearchOptions:

OptionTypeDescription
querystringIf non-empty, the modal opens immediately with results for this query.
onSearch(query) => voidInvoked when the user performs a search (e.g. for tracking).
onDetach() => voidInvoked when the modal is dismissed and focus returns to your native input.
showNativeSearchTogglebooleanOffer users an option to revert to your native search experience.
searchBoxCustomizationsSearchBoxCustomizationsPlaceholder text, font size, icon, borders, and margins.
datasourcesFilterstring[]Restrict results to specific datasources, e.g. ['jira', 'confluence'].

All components also accept the common Optionsbackend, authToken, theme, themeVariant, locale, and more.

Theming

Customize the appearance of Modal Search with SearchBoxCustomizations. The theming system is regularly expanded with additional options based on customer needs.