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

• Global search in headers • Filter search in data tables • Command palette (Cmd+K) • Product or content search

When not to use

• Do not use as a general form input — use input • Avoid for filtering by category — use a select or combobox

Basic example

The following example demonstrates standard usage, fully compliant with Byteion's token-first approach.

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

• Search icon — leading • Input element • Clear button — appears when text exists • Keyboard shortcut badge — optional (Cmd+K)

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-controls
  • aria-expanded
  • aria-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:clear
  • bi:search:error
  • bi:search:load
  • bi:search:query
  • bi: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-source
  • data-bi-search-param
  • data-bi-min-chars
  • data-bi-debounce
  • data-bi-value-field
  • data-bi-label-field
  • data-bi-loading-text
  • data-bi-empty-text
  • data-bi-error-text

Runtime events

  • bi:search:query
  • bi:search:load
  • bi:search:error
  • bi:search:select
  • bi:search:clear
Backend response: Remote endpoints must return JSON. Byteion accepts an array or an object with data, items, results, or options. Each item can be a string/number or an object; value resolves from value, id, or key, and label resolves from label, name, text, or the value. Override object fields with data-bi-value-field and data-bi-label-field.

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

• Best practice: debounce search by 300ms to avoid excessive filtering. • Edge case: on mobile, focus should trigger the appropriate keyboard.

Common mistakes

Avoid hardcoded neutral colors, placeholder-only labels, duplicated primary actions, and missing keyboard states. Keep this component on Byteion tokens so dashboard, admin, POS, ERP, ecommerce back-office, Laravel, React, and Vue starter-kit screens can be rebranded without rewriting markup.

Production usage tips

Use the canonical HTML as the source of truth, keep React and Vue wrappers aligned with the documented variants, test dark mode and branded themes before release, and wire interactive behavior through data-bi-* attributes instead of styling hooks.

Premium examples

Advanced patterns available in Byteion Pro:

• Command palette with fuzzy search and recent history • Inline search suggestions with avatars

Unlock Premium Patterns

Get access to copy-paste ready Pro blocks, SaaS templates, and advanced data-tables built with this component.

Explore Pro Components