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
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.
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.---
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>'use client'
import { Icon, SearchDialog, SearchDialogTrigger, Stack } from '@santi020k/lumen-react'
// 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' }
]
const searchGuides = (query: string) =>
guides.filter(guide => guide.title.toLowerCase().includes(query.toLowerCase()))
export const Example = () => (
<>
<Stack align="start" direction="horizontal" gap="related" wrap>
<SearchDialogTrigger fallbackHref="/guides" target="guide-search" />
<SearchDialogTrigger fallbackHref="/guides" target="guide-search">
<Icon decorative name="search" size="sm" />
Search guides
</SearchDialogTrigger>
</Stack>
<SearchDialog id="guide-search" labels={{ title: 'Search guides' }} search={searchGuides} />
</>
)<script type="module">
import { defineLumenElements } from '@santi020k/lumen-elements/define'
defineLumenElements()
</script>
<lumen-search-dialog-trigger href="/guides" target="guide-search"></lumen-search-dialog-trigger>
<lumen-search-dialog-trigger target="guide-search"><a href="/guides">Search guides</a></lumen-search-dialog-trigger>
<lumen-search-dialog id="guide-search" title-label="Search guides"></lumen-search-dialog>
<script type="module">
// 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' }
]
document.getElementById('guide-search').search = query =>
guides.filter(guide => guide.title.toLowerCase().includes(query.toLowerCase()))
</script>use dioxus::prelude::*;
use lumen_dioxus::prelude::*;
#[component]
fn Example() -> Element {
let docs_search = use_search_dialog();
rsx! {
SearchDialogTrigger {
dialog: docs_search,
fallback_href: "/search",
label: "Search docs",
target: "docs-search",
}
SearchDialog {
dialog: docs_search,
id: "docs-search",
labels: SearchDialogLabels {
title: Some("Search the docs".into()),
..SearchDialogLabels::default()
},
search: move |_query: String| -> SearchDialogFuture { Box::pin(async { Ok(Vec::new()) }) },
}
}
}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.
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.
pnpm add @santi020k/lumen-astrolumen add SearchDialogTriggerpnpm add @santi020k/lumen-reactlumen add SearchDialogTrigger --target reactpnpm add @santi020k/lumen-elementslumen add SearchDialogTrigger --target elementsAPI 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.
| Attribute | Values | Default | Description |
|---|---|---|---|
| target | string | required | The id of the SearchDialog to open. Several triggers can open the same dialog. |
| fallbackHref | string | required | Search page the link opens without JavaScript, before the dialog is ready, and on a modified click such as Ctrl+click. |
| href / <a href> child | string | required | Search 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. |
| label | string | "Search" | Visible text when the trigger has no content of its own. |
| children / default slot | Astro slot | ReactNode | link content | - | Replaces the text, for example with an Icon and a label. The shortcut hint stays after it. |
| class, className | string | "" | Merges custom classes with the generated ui-* root classes. |
| ...native attributes | HTML 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.
.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.
| Hook | Values | Default | Contract |
|---|---|---|---|
| class, className | string | "" | 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.
| Key | Action |
|---|---|
| Enter, Space on the trigger | Open the search dialog. Before the dialog is ready, Enter follows the link. |
| Escape in the dialog | Close the dialog and return focus to the trigger. |