Search
Interactive search input for finding records, pages, files, or remote content. Includes local filtering, clear action, keyboard navigation, async states, and empty/error states.
Overview
The Search component is a core building block of the Byteion design system, providing a robust, accessibility-compliant interface for its specific UI capabilities.
Why this exists
Search inputs need a clear icon, a way to clear the query, and often a dropdown with recent results. A dedicated search component bundles these patterns.
Mental model
A search input is a text field optimized for finding content. It includes a search icon, clear button, and optional suggestions dropdown.
When to use
When not to use
Basic example
The following example demonstrates standard usage, fully compliant with Byteion's token-first approach.
Customer lookup
Search is for finding records or content. Try typing "acme", "invoice", or "overdue".
No matching records
Try a customer name, invoice number, or status tag.
Compact page search
A lighter searchbox for headers, docs pages, and sidebars.
Async states
Use these panel states for remote API search.
No results
Try another keyword or clear filters.
Could not load results
Keep the query and retry the request.
import { useState } from 'react';
import { Search } from '@byteion/react';
export default function SearchDemo() {
const [query, setQuery] = useState('');
return (
<div className="grid max-w-md gap-4 p-6">
<Search placeholder="Search projects" value={query} onChange={setQuery} />
<Search placeholder="Press ⌘K to search" shortcut="⌘K" />
<Search placeholder="Disabled" disabled />
</div>
);
}
<script setup lang="ts">
import { ref } from 'vue';
import { Search } from '@byteion/vue';
const query = ref('');
</script>
<template>
<div class="grid max-w-md gap-4 p-6">
<Search v-model="query" placeholder="Search projects" />
<Search placeholder="Press ⌘K to search" shortcut="⌘K" />
<Search placeholder="Disabled" disabled />
</div>
</template>
Variants
Each variant communicates a different meaning. Choose based on priority, not aesthetics.
Single default variant.
Sizes
Size should match the importance and context of the component.
- md — md size.
States
This component reacts seamlessly to the following interaction and data states:
- idle — idle state.
- focus — Keyboard or tab focus — shows ring indicator for accessibility.
- open — Component is expanded or visible.
- default — Resting appearance before interaction.
- hover — Pointer is over the element — visual feedback via color or shadow.
- active — Currently selected or in use.
- disabled — Non-interactive — grayed out, cursor not-allowed.
Anatomy
Usage guidelines
- Place search icon on the left.
- Show clear button only when there is text.
- Use Cmd+K shortcut for global search.
Do and Don't
Do
- Include a clear button.
- Use the search icon.
- Support keyboard shortcuts.
Don't
- Do not show clear button on empty input.
- Do not auto-search on every keystroke without debounce.
- Do not use a generic input without search affordances.
Accessibility
Native input with search role. Clear button must be a button element.
Role:searchbox + listbox
ARIA Attributes
aria-controlsaria-expandedaria-activedescendant
Keyboard Navigation
- ArrowDown
- ArrowUp
- Home
- End
- Enter
- Escape
Customization
Follows input tokens.
Compose with React cva()
Use the exportedcva() +cn() utilities to compose your own variant on top of the Byteion tokens.
import { cva, cn, type VariantProps } from '@byteion/react';
const mySearch = cva('base classes…', {
variants: {
accent: { soft:'border-primary-200', loud:'border-primary-500' },
},
defaultVariants: { accent:'soft' },
});
type Props = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof mySearch>;
Compose with Vue cva()
Use the exportedcva() +cn() utilities inside standard Vue setup blocks.
<script setup lang="ts">
import { computed, useAttrs } from 'vue';
import { cva, type VariantProps } from '@byteion/vue';
interface Props { accent?:'soft' |'loud' }
const props = withDefaults(defineProps<Props>(), { accent:'soft' });
const attrs = useAttrs();
const mySearch = cva('base classes…', {
variants: { accent: { soft:'border-primary-200', loud:'border-primary-500' } },
});
const cls = computed(() => mySearch({ accent: props.accent, class: attrs.class as string | undefined }));
</script>
Runtime events
Byteion keeps framework APIs idiomatic: HTML uses DOM custom events, React uses callback props, and Vue uses emitted events / v-model updates.
HTML / JS events
bi:search:clearbi:search:errorbi:search:loadbi:search:querybi:search:select
React callbacks
No React callback events are declared by this adapter.
Vue emits
update:modelValue[value: string]
Remote / AJAX
Remote search
Add data-bi-source to query a backend search endpoint. The runtime manages aria-busy, data-bi-async-state, keyboard navigation, loading, empty, and error states.
Attributes
data-bi-sourcedata-bi-search-paramdata-bi-min-charsdata-bi-debouncedata-bi-value-fielddata-bi-label-fielddata-bi-loading-textdata-bi-empty-textdata-bi-error-text
Runtime events
bi:search:querybi:search:loadbi:search:errorbi:search:selectbi:search:clear
Accessibility: loading sets aria-busy="true"; empty states use role="status"; error states use alert/status messaging where the runtime renders remote status rows.
API Reference
Enhanced input with clear button trigger.
HTML Data Attributes
No custom data attributes required.
React Props · SearchProps
Extracted directly fromreact/src/components/Search.tsx.
export interface SearchProps
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'size'> {
/** Keyboard shortcut hint shown on the right edge (e.g. "⌘K"). */
shortcut?: ReactNode;
/** Visual style. */
variant?: 'default' | 'compact';
/** Optional accessible label override. */
'aria-label'?: string;
}
Vue Props · SearchProps
Extracted directly fromvue/src/components/Search.vue.
export interface SearchProps {
modelValue?: string;
/** Keyboard shortcut hint shown on the right edge (e.g. "⌘K"). */
shortcut?: string;
/** Visual style. */
variant?: 'default' | 'compact';
placeholder?: string;
ariaLabel?: string;
id?: string;
}
Developer tips
Common mistakes
Production usage tips
data-bi-* attributes instead of styling hooks.
Premium examples
Advanced patterns available in Byteion Pro:
Related components
Unlock Premium Patterns
Get access to copy-paste ready Pro blocks, SaaS templates, and advanced data-tables built with this component.
Explore Pro Components