Search Palette
Search Palette component
Install
npx ui8kit add search-palettePulls in: box, compose, inline, input, kit-box, kit-input, kit-text, lucide-icon, utils
Preview
Code
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdnnpx ui8kit add search-palette<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- A search field with a search glyph and the keys that open it. -->
<script lang="ts" module>
import type { Snippet } from "svelte";
export type SearchPaletteProps = {
label: string;
shortcut: string;
};
</script>
<script lang="ts">
import Box from "../compose/Box.svelte";
import Inline from "../compose/Inline.svelte";
import Input from "../compose/Input.svelte";
import LucideIcon from "../icons/LucideIcon.svelte";
let { label, shortcut }: SearchPaletteProps = $props();
</script>
<Box class="relative w-full max-w-sm" data-slot="palette">
<LucideIcon name="search" size={16} class="pointer-events-none absolute top-2 left-3 text-muted-foreground" />
<Input type="search" size="sm" placeholder={label} aria-label={label} class="pr-12 pl-10" />
<Inline
class={"pointer-events-none absolute top-2 right-2 rounded px-2 py-0 text-xs text-muted-foreground inset-ring " +
"inset-ring-border"}
>
{shortcut}
</Inline>
</Box>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdnnpx ui8kit add search-palette// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** A search field with a search glyph and the keys that open it. */
import { type ReactNode } from "react";
import { Box, Inline, Input } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
export type SearchPaletteProps = {
label: string;
shortcut: string;
};
export function SearchPalette({ label, shortcut }: SearchPaletteProps) {
return (
<Box className="relative w-full max-w-sm" data-slot="palette">
<LucideIcon name="search" size={16} className="pointer-events-none absolute top-2 left-3 text-muted-foreground" />
<Input type="search" size="sm" placeholder={label} aria-label={label} className="pr-12 pl-10" />
<Inline
className={"pointer-events-none absolute top-2 right-2 rounded px-2 py-0 text-xs text-muted-foreground inset-ring " +
"inset-ring-border"}
>
{shortcut}
</Inline>
</Box>
);
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdnnpx ui8kit add search-palette<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!-- A search field with a search glyph and the keys that open it. -->
<script lang="ts">
export type SearchPaletteProps = {
label: string;
shortcut: string;
};
</script>
<script setup lang="ts">
import Box from "../compose/Box.vue";
import Inline from "../compose/Inline.vue";
import Input from "../compose/Input.vue";
import LucideIcon from "../icons/LucideIcon.vue";
const { label, shortcut } = defineProps<SearchPaletteProps>();
</script>
<template>
<Box class="relative w-full max-w-sm" data-slot="palette">
<LucideIcon name="search" :size="16" class="pointer-events-none absolute top-2 left-3 text-muted-foreground" />
<Input type="search" size="sm" :placeholder="label" :aria-label="label" class="pr-12 pl-10" />
<Inline
:class="'pointer-events-none absolute top-2 right-2 rounded px-2 py-0 text-xs text-muted-foreground inset-ring ' +
'inset-ring-border'"
>
{{ shortcut }}
</Inline>
</Box>
</template>
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdnnpx ui8kit add search-palette// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/** A search field with a search glyph and the keys that open it. */
import { type JSX } from "solid-js";
import { Box, Inline, Input } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
export type SearchPaletteProps = {
label: string;
shortcut: string;
};
export function SearchPalette({ label, shortcut }: SearchPaletteProps) {
return (
<Box class="relative w-full max-w-sm" data-slot="palette">
<LucideIcon name="search" size={16} class="pointer-events-none absolute top-2 left-3 text-muted-foreground" />
<Input type="search" size="sm" placeholder={label} aria-label={label} class="pr-12 pl-10" />
<Inline
class={"pointer-events-none absolute top-2 right-2 rounded px-2 py-0 text-xs text-muted-foreground inset-ring " +
"inset-ring-border"}
>
{shortcut}
</Inline>
</Box>
);
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdnnpx ui8kit add search-palette// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/organisms/search-palette.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/icons"
"github.com/ui8kit/codegen/generated/templ/ui/input"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// SearchPaletteProps are the props of SearchPalette; the values are the JSON shapes of the TypeScript props.
type SearchPaletteProps struct {
Label any `json:"label"`
Shortcut any `json:"shortcut"`
}
// A search field with a search glyph and the keys that open it.
templ SearchPalette(p SearchPaletteProps) {
{{ vLabel := p.Label }}
{{ vShortcut := p.Shortcut }}
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "relative w-full max-w-sm", Attrs: uiutils.Attrs("data-slot", "palette")}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "search", Size: 16, Class: "pointer-events-none absolute top-2 left-3 text-muted-foreground"})
@compose.Input(compose.InputProps{Size: "sm", InputProps: input.InputProps{Type: "search", Placeholder: uiutils.S(vLabel), Class: "pr-12 pl-10", Attrs: uiutils.Attrs("aria-label", vLabel)}})
@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "pointer-events-none absolute top-2 right-2 rounded px-2 py-0 text-xs text-muted-foreground inset-ring inset-ring-border"}}) {
{ uiutils.Text(vShortcut) }
}
}
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdnnpx ui8kit add search-palette{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/search-palette.json
A search field with a search glyph and the keys that open it.
Props (p): label, shortcut. -#}
{%- set v_label = (p.label ?? null) -%}
{%- set v_shortcut = (p.shortcut ?? null) -%}
{%- set c_2 -%}
{{ include('icons/LucideIcon.html.twig', {'name': 'search', 'size': 16, 'class': 'pointer-events-none absolute top-2 left-3 text-muted-foreground'}, with_context = false) }}
{{ include('compose/Input.html.twig', {'type': 'search', 'size': 'sm', 'placeholder': og_s(v_label), 'class': 'pr-12 pl-10', 'attrs': og_attrs(['aria-label', v_label])}, with_context = false) }}
{%- set c_1 -%}
{{ og_text(v_shortcut) }}
{%- endset -%}
{{ include('compose/Inline.html.twig', {'class': 'pointer-events-none absolute top-2 right-2 rounded px-2 py-0 text-xs text-muted-foreground inset-ring inset-ring-border', 'children': c_1}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'relative w-full max-w-sm', 'attrs': og_attrs(['data-slot', 'palette']), 'children': c_2}, with_context = false) }}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdnnpx ui8kit add search-palette{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/search-palette.json
A search field with a search glyph and the keys that open it.
Props (p): label, shortcut. *}
{var $v_label = ($p['label'] ?? null)}
{var $v_shortcut = ($p['shortcut'] ?? null)}
{capture $c_2}
{=og_include('icons/LucideIcon.latte', ['name' => 'search', 'size' => 16, 'class' => 'pointer-events-none absolute top-2 left-3 text-muted-foreground'])|noescape}
{=og_include('compose/Input.latte', ['type' => 'search', 'size' => 'sm', 'placeholder' => og_s($v_label), 'class' => 'pr-12 pl-10', 'attrs' => og_attrs(['aria-label', $v_label])])|noescape}
{capture $c_1}
{=og_text($v_shortcut)}
{/capture}
{=og_include('compose/Inline.latte', ['class' => 'pointer-events-none absolute top-2 right-2 rounded px-2 py-0 text-xs text-muted-foreground inset-ring inset-ring-border', 'children' => (string) $c_1])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'relative w-full max-w-sm', 'attrs' => og_attrs(['data-slot', 'palette']), 'children' => (string) $c_2])|noescape}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdnnpx ui8kit add search-palette{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
Source: packages/compose-gen/specs/organisms/search-palette.json
A search field with a search glyph and the keys that open it.
Props (p): label, shortcut. -#}
{%- set v_label = og_def(p['label'], none) -%}
{%- set v_shortcut = og_def(p['shortcut'], none) -%}
{%- set c_2 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'search', 'Size': 16, 'Class': 'pointer-events-none absolute top-2 left-3 text-muted-foreground'}}) }}
{{ og_include('compose/input.html.j2', {'p': {'Type': 'search', 'Size': 'sm', 'Placeholder': og_s(v_label), 'Class': 'pr-12 pl-10', 'Attrs': og_attrs(['aria-label', v_label])}}) }}
{%- set c_1 -%}
{{ og_text(v_shortcut) }}
{%- endset -%}
{{ og_include('compose/inline.html.j2', {'p': {'Class': 'pointer-events-none absolute top-2 right-2 rounded px-2 py-0 text-xs text-muted-foreground inset-ring inset-ring-border'}, 'children': c_1}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'relative w-full max-w-sm', 'Attrs': og_attrs(['data-slot', 'palette'])}, 'children': c_2}) }}
Props
Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.
A search field with a search glyph and the keys that open it.
| Prop | Type | Default | Description |
|---|---|---|---|
| label (required) | string | - | name and placeholder of the field |
| shortcut (required) | string | - |