Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Web docs
Overlays

SearchDialogTrigger

Links to a search page and, once enhanced, opens a SearchDialog with a Ctrl K or Command K hint.

Frameworks
Astro · React · Elements · Dioxus
Registry
lumen add SearchDialogTrigger
Interaction
Enhanced runtime
01

See it and copy it

Framework example

Choose Astro, React, Elements, or Dioxus to compare native usage against the shared visual output. Each example assumes the framework-level setup is already complete.

AstroCode target · live preview uses Astro

Search guides

    View SearchDialogTrigger code

    Framework usage

    Switch targets to compare the adapter code. This live preview runs the Astro example. Before copying an example, complete the matching framework setup; React, Elements, and Dioxus use their own behavior APIs.Width controls resize the preview container. Resize your browser to test viewport breakpoints.
    astro
    ---
    import { Icon, SearchDialog, SearchDialogTrigger, Stack } from '@santi020k/lumen-astro'
    ---
    
    {/* These docs already open their own search with Ctrl+K, so the example turns the shortcut off. */}
    <Stack align="start" direction="horizontal" gap="related" wrap>
      <SearchDialogTrigger fallbackHref="/guides" target="search-dialog-trigger-example" />
      <SearchDialogTrigger fallbackHref="/guides" target="search-dialog-trigger-example">
        <Icon decorative name="search" size="sm" />
        Search guides
      </SearchDialogTrigger>
    </Stack>
    <SearchDialog id="search-dialog-trigger-example" labels={{ title: 'Search guides' }} shortcut={false} />
    
    <script>
      import { bindLumenSearchDialog } from '@santi020k/lumen-astro/search-dialog'
    
      // Illustrative only: query your own search index or API here.
      const guides = [
        { href: '/guides/build-an-astro-starter', title: 'Build an Astro starter' },
        { href: '/guides/build-an-editorial-article', title: 'Build an editorial article' },
        { href: '/guides/ship-a-settings-screen', title: 'Ship a settings screen' }
      ]
    
      bindLumenSearchDialog('search-dialog-trigger-example', query =>
        guides.filter(guide => guide.title.toLowerCase().includes(query.toLowerCase()))
      )
    </script>
    Edit SearchDialogTrigger in browser

    Framework differences

    React: The trigger is a plain link to fallbackHref until its SearchDialog mounts, and it may render before or after the dialog.

    Elements: Wrap an <a href> in <lumen-search-dialog-trigger target="site-search"> so the link works before the element upgrades, or set href and label on the host and let it create the link.

    02

    Choose your target

    Add this component

    Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

    bash@santi020k/lumen-astro
    pnpm add @santi020k/lumen-astro
    bashAstro wrapper
    lumen add SearchDialogTrigger

    API reference

    Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.

    AttributeValuesDefaultDescription
    targetstringrequiredThe id of the SearchDialog to open. Several triggers can open the same dialog.
    fallbackHrefstringrequiredSearch page the link opens without JavaScript, before the dialog is ready, and on a modified click such as Ctrl+click.
    href / <a href> childstringrequiredSearch page the link opens without JavaScript, before the dialog is ready, and on a modified click. Author an <a href> child so the link works before the element upgrades, or set href on the host.
    labelstring"Search"Visible text when the trigger has no content of its own.
    children / default slotAstro slot | ReactNode | link content-Replaces the text, for example with an Icon and a label. The shortcut hint stays after it.
    class, classNamestring""Merges custom classes with the generated ui-* root classes.
    ...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

    Customize SearchDialogTrigger

    Start with semantic theme tokens and a class on the public component. Keep its accessible name, focus treatment, and interaction state intact.

    cssScoped theme overrides
    .product-search-dialog-trigger {
      --surface: 0 0% 100%;
      --ink: 220 20% 15%;
      --line: 220 15% 82%;
    }

    Apply product-search-dialog-trigger through Astro's class, React's className, or the custom element's class. Verify foreground and background contrast in both schemes.

    HookValuesDefaultContract
    class, classNamestring""Merges custom classes with the generated ui-* root classes.

    Use the documented hooks above and adapter types when targeting component states. Theme guide · Accessibility verification scope

    Keyboard interactions

    Keyboard behavior provided by the Astro UIPrimitives runtime for this component.

    KeyAction
    Enter, Space on the triggerOpen the search dialog. Before the dialog is ready, Enter follows the link.
    Escape in the dialogClose the dialog and return focus to the trigger.

    Web docsFull catalog