Styling

The packages do not ship styles. Classes, attributes, and popup positioning belong to your markup. The core exposes the state and the anchor values; the adapter leaves the DOM to you.

Popup positioning

For a popup in the browser top layer, put cssAnchorName on the trigger as anchor-name, then put popupStyle on the popup and set the popover attribute to manual. The style object contains the anchor reference, insets, and margins. The exact binding syntax depends on the adapter.

If you render the popup conditionally instead of using the Popover API, skip popover. Position it with the same anchor values or with your own layout.

.cbx-popup {
  inset: auto;
  position-try: flip-block;
  opacity: 0;
  margin-block-start: 0;

  @media (prefers-reduced-motion: no-preference) {
    transition:
      opacity 0.15s ease,
      margin-block-start 0.15s ease,
      overlay 0.15s ease allow-discrete,
      display 0.15s ease allow-discrete;
  }

  &:not(:popover-open) {
    display: none;
  }

  &:popover-open {
    opacity: 1;
    margin-block-start: 0.5rem;

    @starting-style {
      opacity: 0;
      margin-block-start: 0;
    }
  }
}

The selector is arbitrary. The important parts are position-try: flip-block, hiding the popup unless it is :popover-open, and animating the entry with @starting-style. The overlay and display transitions keep the top-layer switch animatable.

State for classes

Use the scope values to choose classes or attributes. The examples use daisyUI classes, but any CSS works.

NameTypeDescription
isOpenbooleanShow the popup, or drive popover.showPopover() and hidePopover().
cssAnchorNamestringPut it on the trigger as anchor-name. The popup uses position-anchor from popupStyle.
popupStyleHeadlessComboboxPopupStylePositioning values for the popup: position-anchor, inset, margin, and width.
isSelected(option)booleanStyle the selected option.
highlightedIndexnumberStyle the keyboard and hover highlight. Compare it with the option index.
selectedCountnumberShow a count, a badge, or disabled state.
validbooleanStyle the field and validation message.
errorsHeadlessComboboxErrorCode[]Render a specific message for each error code.

Keep the behavior accessible

Do not replace the ARIA prop bags with your own roles or handlers. Spread triggerProps, comboboxInputProps, inputProps, listboxProps, and getOptionProps onto the matching elements, then add classes and styles around them.

For a typeahead, the input receives comboboxInputProps and also acts as the trigger. For a button trigger, use triggerProps. Do not put both on the same element.