Search Field
Query input with a search icon and a clear button.
Query: —
Import
Section titled “Import”import { SearchField } from "@pelagornis/page/components";Example
Section titled “Example”The preview above renders this file. Copy it into src/components/ to start from it.
import { useState } from "react";import { SearchField, Stack, Text } from "@pelagornis/page/components";
export default function SearchFieldDemo() { const [query, setQuery] = useState("");
return ( <Stack gap="sizeSmall" className="w-full max-w-sm"> <SearchField value={query} onValueChange={setQuery} aria-label="Search components" /> <SearchField appearance="plain" defaultValue="tokens" aria-label="Plain search" /> <Text variant="captionMd">Query: {query || "—"}</Text> </Stack> );}Use in MDX
Section titled “Use in MDX”Search Field can be written straight in an .mdx page. Import it below the frontmatter. It responds to input, so add client:load to hydrate it.
---title: Example---
import { SearchField } from "@pelagornis/page/components";
<SearchField client:load defaultValue="tokens" aria-label="Search" />Use in Markdoc
Section titled “Use in Markdoc”Markdoc tags render Astro components, and this one needs client state. Wrap the example in an .astro file that hydrates it, then register that file as a tag.
---import SearchFieldExample from "../SearchFieldExample";---
<SearchFieldExample client:load />import { component, defineMarkdocConfig } from "@astrojs/markdoc/config";import starlightMarkdoc from "@astrojs/starlight-markdoc";import pageMarkdoc from "@pelagornis/page/markdoc";
export default defineMarkdocConfig({ extends: [starlightMarkdoc(), pageMarkdoc()], tags: { "search-field-example": { render: component("./src/components/markdoc/SearchFieldExample.astro"), selfClosing: true, }, },});{% search-field-example /%}Variants
Section titled “Variants”Values the component accepts for each variant prop.
| Prop | Values |
|---|---|
appearance | filled plain |
size | sm md lg |
Anatomy
Section titled “Anatomy”Parts of the component and the data-refineui role each one renders.
| Part | Role |
|---|---|
root | search-field |
clear | search-field-clear |
icon | search-field-icon |
input | search-field-input |
States
Section titled “States”States the component styles. Component states are exposed as data attributes.
| Kind | States |
|---|---|
| Pseudo | focus-visible |
Keyboard
Section titled “Keyboard”Keys the component handles when it has focus.
| Key | Action |
|---|---|
| Escape | close |
Reference
Section titled “Reference”- RefineUI · Search Field for design guidance and token detail.
- Use in MDX and Use in Markdoc for the general rules.