All files / packages/design-system-2-site/src/components/ui SearchBar.tsx

100% Statements 3/3
100% Branches 2/2
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 393x                                                   26x           4x            
'use client';
 
import { SearchIcon } from '@/components/icons';
import { Input } from '@/components/ui/Input';
 
interface SearchBarProps {
  value: string;
  onChange: (value: string) => void;
  placeholder?: string;
  /** Accessible name; defaults to "Search". */
  label?: string;
  /** Extra classes for the outer `.field` wrapper. */
  className?: string;
}
 
/**
 * A standard text field (`Input`) with a leading magnifier, so it inherits the
 * field states and theme tokens. No results dropdown.
 */
export function SearchBar({
  value,
  onChange,
  placeholder = 'Search…',
  label = 'Search',
  className,
}: SearchBarProps) {
  return (
    <Input
      type="search"
      aria-label={label}
      iconLeft={<SearchIcon />}
      value={value}
      onChange={(e) => onChange(e.target.value)}
      placeholder={placeholder}
      containerClassName={className}
    />
  );
}