Skip to content

Search

Open a command-palette style search dialog from a compact trigger. Result data is supplied by the caller.

Default Rendered example
Usage Example

Custom Results

Use Item fields and Attrs to decide where results navigate and how they integrate with the host app.

Custom Results Rendered example
Custom Results
@search.Search(search.Config{
    ID:           "custom-search",
    Label:        "Search patterns",
    Placeholder:  "Try form, modal, or nav",
    ShortcutText: "Ctrl K",
    Items: []search.Item{
        {Title: "Form controls", Section: "Guide", Keywords: []string{"input select checkbox"}},
        {Title: "Overlay flows", Section: "Guide", Keywords: []string{"modal drawer search"}},
    },
})

Fuzzy Results

Set MatchModeFuzzy to rank deterministic compact subsequence matches after exact substring matches.

Fuzzy Results Rendered example
Fuzzy Results
@search.Search(search.Config{
    ID:        "fuzzy-search",
    MatchMode: search.MatchModeFuzzy,
    Items: []search.Item{
        {Title: "Search result map", Href: "/components/search"},
    },
})

Remote Results

Load result records from a JSON endpoint, then fuzzy-rank and navigate in the browser.

Remote Results Rendered example
Remote Results
@search.Search(search.Config{
    ID:          "remote-search",
    Label:       "Remote search",
    Placeholder: "Search fetched results",
    ItemsURL:    "/api/components/search/items",
	MatchMode:    search.MatchModeFuzzy,
})

Go API

v0.2.7

The examples above cover behavior and composition. pkg.go.dev is the canonical reference for exported types, functions, methods, and Go documentation.

github.com/araihu/goshtoso/components/search
Open v0.2.7 API