LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. Components

Combobox

Also called autocomplete, typeahead, or searchable select

A text field with a dropdown list that filters as you type, so people can pick one option from a long list quickly.

import { useState } from 'react';
import { Combobox } from '@base-ui/react/combobox';

const CITIES = ['Berlin', 'Boston', 'Lisbon', 'London', 'Paris', 'Tokyo'];

export function CityCombobox() {
  const [query, setQuery] = useState('');

  // Base UI wires up role='combobox', aria-expanded, and aria-activedescendant.
  return (
    <Combobox.Root
      items={CITIES}
      limit={8}
      inputValue={query}
      onInputValueChange={setQuery}
    >
      <label className='flex w-64 flex-col gap-1.5 text-sm font-medium'>
        City
        <Combobox.Input
          placeholder='Start typing a city'
          className='h-10 rounded-lg border bg-background px-3 font-normal outline-none focus:ring-2 focus:ring-ring'
        />
      </label>
      <Combobox.Portal>
        <Combobox.Positioner sideOffset={4}>
          <Combobox.Popup className='w-(--anchor-width) origin-(--transform-origin) rounded-lg border bg-background p-1 shadow-lg transition-[opacity,scale] duration-100 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0'>
            <Combobox.Empty className='px-3 py-2 text-sm text-muted-foreground empty:p-0'>
              No matches
            </Combobox.Empty>
            <Combobox.List>
              {(city: string) => (
                <Combobox.Item
                  key={city}
                  value={city}
                  className='cursor-default rounded-md px-3 py-2 text-sm outline-none select-none data-highlighted:bg-muted'
                >
                  <Highlight text={city} query={query} />
                </Combobox.Item>
              )}
            </Combobox.List>
          </Combobox.Popup>
        </Combobox.Positioner>
      </Combobox.Portal>
    </Combobox.Root>
  );
}

// Bolds the part of the city name that matches what was typed.
function Highlight({ text, query }: { text: string; query: string }) {
  const start = query ? text.toLowerCase().indexOf(query.toLowerCase()) : -1;
  if (start < 0) return text;
  const end = start + query.length;
  return (
    <>
      {text.slice(0, start)}
      <strong>{text.slice(start, end)}</strong>
      {text.slice(end)}
    </>
  );
}
Turn the City field into a combobox: as people type, show up to 8 matching cities below the input with the matching letters in bold. Support Up, Down, Enter to choose, and Escape to close, and close the list when the field loses focus. Use role='combobox' with aria-expanded and aria-activedescendant, and show 'No matches' when nothing fits.

Paste into Layerwise or any AI coding tool.

What is Combobox?

A combobox pairs an input with a list of options. As you type, the list narrows to the matches, often with the matching letters in bold. Arrow keys move through the results, Enter or a click picks one, and the field then shows the chosen value.

Use it when a plain select would be too long to scroll, such as countries, cities, time zones, or teammates. With fewer than about seven options, a select or radio buttons are quicker. Decide whether people may enter a value that is not in the list, like a new tag, and make that clear.

Filter on every keystroke for short local lists. When results come from a server, debounce requests by about 150 to 300ms and show a loading state. Follow the ARIA combobox pattern, with role='combobox', aria-expanded, and aria-activedescendant, so screen readers announce the highlighted option. The native <datalist> element gives a basic version with no script, though its list can't be styled.

Often confused with

Dropdown menu
A dropdown menu runs an action when you pick an item. A combobox fills in a value for a field and lets you type to filter.
Command palette
A command palette searches every action in the app. A combobox searches the options for one field.

Related terms

All terms

Debounce

A technique that waits for a short pause in typing or other repeated events, then runs the work once instead of on every keystroke.

Tag input

A text field where each word you type becomes a removable chip when you press Enter or a comma, for adding labels, emails, or keywords.

Command palette

A search box that opens with a shortcut like ⌘K and lets you find and run any command or page by typing a few letters.

Inline validation

Form checking that happens right next to each field as you fill it in, showing an error or a checkmark before you press Submit.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit