import { Combobox } from "@replicas/ui";

const statuses = ["Draft", "In review", "Approved", "Published", "Archived"];

export default function ComboboxDemo() {
  return (
    <Combobox.Root items={statuses} defaultValue="Draft">
      <Combobox.Trigger aria-label="Status">
        <Combobox.Value />
      </Combobox.Trigger>
      <Combobox.Popup aria-label="Change status">
        <Combobox.Input placeholder="Change status..." />
        <Combobox.Empty>No results</Combobox.Empty>
        <Combobox.List>
          {(status: string) => (
            <Combobox.Item key={status} value={status} shortcut={statuses.indexOf(status) + 1}>
              {status}
            </Combobox.Item>
          )}
        </Combobox.List>
      </Combobox.Popup>
    </Combobox.Root>
  );
}

Prompt

Copy Prompt hands your agent everything it needs to build the Combobox in the Palermo style: the measured tokens, the CSS and the structure.

Show Prompt
# Palermo Combobox

An input combined with a list of predefined items to select.

Build a Combobox in this project that looks and behaves like Palermo's. Measured from the running Palermo app (palermo.tryprofound.com). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or [Base UI](https://base-ui.com/react/components/combobox) if it has none.

Fidelity: Partly measured from Palermo's Combobox. No reference has been captured yet.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--color-bg-secondary` | `#fafafa` | `#1e1d1c` |
| `--text-primary` | `#18181a` | `#ecebe9` |
| `--text-secondary` | `#787878` | `#aaa8a5` |
| `--text-tertiary` | `#969696` | `#898784` |
| `--text-quaternary` | `#b4b4b4` | `#676563` |
| `--surface-bg` | `#fff` | `#171615` |
| `--surface-divider` | `#e8e8e8` | `#232221` |
| `--surface-text` | `#18181a` | `#ecebe9` |
| `--surface-highlight` | `#f5f5f5` | `#272625` |
| `--chip-bg` | `#fff` | `#1e1d1c` |
| `--chip-bg-hover` | `#f5f5f5` | `#252423` |
| `--chip-text` | `#18181a` | `#ecebe9` |
| `--shadow-low` | `var(--surface-shadow-low), var(--shadow-border)` | `var(--surface-shadow-low), var(--shadow-border)` |
| `--shadow-high` | `var(--surface-shadow-high), var(--shadow-border)` | `var(--surface-shadow-high), var(--shadow-border)` |
| `--focus-ring` | `#006bff` | `#006bff` |
| `--font-regular` | `"Profound Inter", "Inter Variable", "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif` | `"Profound Inter", "Inter Variable", "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif` |
| `--font-size-mini` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.8125rem` | `0.8125rem` |
| `--line-height-mini` | `16px` | `16px` |
| `--line-height-small` | `18px` | `18px` |
| `--font-weight-normal` | `400` | `400` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-control` | `8px` | `8px` |
| `--ease-popup` | `ease` | `ease` |
| `--duration-fast` | `100ms` | `100ms` |

## CSS

Scoped under `[data-style="palermo"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.

```css
[data-style="palermo"] {
  .ui-combobox-trigger {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    margin: 0;
    padding: 0 8px;
    border: 0;
    border-radius: var(--radius-control);
    background-color: var(--chip-bg);
    box-shadow: var(--shadow-low);
    color: var(--chip-text);
    font-family: inherit;
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-small);
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    outline: none;

    @media (hover: hover) {
      &:hover:not([data-disabled]) {
        background-color: var(--chip-bg-hover);
      }
    }

    &:focus-visible {
      outline: 1px solid var(--focus-ring);
      outline-offset: -1px;
    }

    &[data-disabled] {
      background-color: var(--color-bg-secondary);
      box-shadow: none;
      color: var(--text-quaternary);
      cursor: not-allowed;
    }

    & svg {
      width: 16px;
      height: 16px;
      flex-shrink: 0;
      color: var(--text-secondary);
    }
  }

  .ui-combobox-positioner {
    outline: none;
  }

  .ui-combobox-popup {
    box-sizing: border-box;
    min-width: max(249px, var(--anchor-width));
    max-width: var(--available-width);
    overflow: hidden;
    border-radius: var(--radius-control);
    background-color: var(--surface-bg);
    box-shadow: var(--shadow-high);
    color: var(--surface-text);
    font-family: var(--font-regular);
    font-size: var(--font-size-small);
    line-height: var(--line-height-small);
    -webkit-font-smoothing: antialiased;
    outline: none;
    transition: opacity var(--duration-fast) var(--ease-popup);

    &[data-ending-style] {
      opacity: 0;
    }

    &[data-side="bottom"] {
      translate: 0 6px;
    }

    &[data-side="top"] {
      translate: 0 -6px;
    }

    &[data-side="left"] {
      translate: -6px 0;
    }

    &[data-side="right"] {
      translate: 6px 0;
    }
  }

  .ui-combobox-input {
    box-sizing: border-box;
    display: block;
    width: 100%;
    height: 36px;
    margin: 0;
    padding: 0 10px;
    border: 0;
    border-bottom: 1px solid var(--surface-divider);
    border-radius: 0;
    background-color: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-small);
    outline: none;

    &::placeholder {
      color: var(--text-tertiary);
    }
  }

  .ui-combobox-list {
    box-sizing: border-box;
    max-height: min(320px, calc(var(--available-height) - 36px));
    padding: 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-block: 4px;
    outline: none;

    &:empty {
      padding: 0;
    }
  }

  .ui-combobox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius-control);
    color: var(--surface-text);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    user-select: none;
    outline: none;

    &[data-highlighted] {
      background-color: var(--surface-highlight);
    }

    &[data-disabled] {
      opacity: 0.5;
      pointer-events: none;
    }
  }

  .ui-combobox-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ui-combobox-indicator {
    display: flex;
    color: var(--text-secondary);

    & svg {
      width: 16px;
      height: 16px;
    }
  }

  .ui-combobox-shortcut {
    margin-left: auto;
    padding-left: 16px;
    color: var(--text-tertiary);
    font-size: var(--font-size-mini);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-mini);
  }

  .ui-combobox-empty:not(:empty) {
    padding: 8px;
    color: var(--text-tertiary);
    font-size: var(--font-size-small);
  }

  .ui-combobox-separator {
    height: 1px;
    margin: 4px -4px;
    background-color: var(--surface-divider);
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
import type { ReactNode } from "react";
import { usePortalContainer } from "./portal";

const join = (base: string, extra?: string) => (extra ? `${base} ${extra}` : base);

function Trigger({ className, ...props }: Omit<BaseCombobox.Trigger.Props, "className"> & { className?: string }) {
  return <BaseCombobox.Trigger className={join("ui-combobox-trigger", className)} {...props} />;
}

type PopupProps = Omit<BaseCombobox.Popup.Props, "className"> & {
  className?: string;
  side?: BaseCombobox.Positioner.Props["side"];
  align?: BaseCombobox.Positioner.Props["align"];
  sideOffset?: number;
};

function Popup({ className, side = "bottom", align = "start", sideOffset = 4, ...props }: PopupProps) {
  return (
    <BaseCombobox.Portal container={usePortalContainer()}>
      <BaseCombobox.Positioner className="ui-combobox-positioner" side={side} align={align} sideOffset={sideOffset}>
        <BaseCombobox.Popup className={join("ui-combobox-popup", className)} {...props} />
      </BaseCombobox.Positioner>
    </BaseCombobox.Portal>
  );
}

function Input({ className, ...props }: Omit<BaseCombobox.Input.Props, "className"> & { className?: string }) {
  return <BaseCombobox.Input className={join("ui-combobox-input", className)} {...props} />;
}

function List({ className, ...props }: Omit<BaseCombobox.List.Props, "className"> & { className?: string }) {
  return <BaseCombobox.List className={join("ui-combobox-list", className)} {...props} />;
}

type ItemProps = Omit<BaseCombobox.Item.Props, "className"> & {
  className?: string;
  shortcut?: ReactNode;
};

function Item({ className, shortcut, children, ...props }: ItemProps) {
  return (
    <BaseCombobox.Item className={join("ui-combobox-item", className)} {...props}>
      <span className="ui-combobox-label">{children}</span>
      <BaseCombobox.ItemIndicator className="ui-combobox-indicator">
        <svg viewBox="0 0 16 16" fill="none" aria-hidden>
          <path d="M3.5 8.5l3 3 6-7" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
        </svg>
      </BaseCombobox.ItemIndicator>
      {shortcut !== undefined ? <span className="ui-combobox-shortcut">{shortcut}</span> : null}
    </BaseCombobox.Item>
  );
}

function Empty({ className, ...props }: Omit<BaseCombobox.Empty.Props, "className"> & { className?: string }) {
  return <BaseCombobox.Empty className={join("ui-combobox-empty", className)} {...props} />;
}

function Separator({ className, ...props }: Omit<BaseCombobox.Separator.Props, "className"> & { className?: string }) {
  return <BaseCombobox.Separator className={join("ui-combobox-separator", className)} {...props} />;
}

export const Combobox = {
  Root: BaseCombobox.Root,
  Trigger,
  Value: BaseCombobox.Value,
  Popup,
  Input,
  List,
  Item,
  Empty,
  Separator,
};
```

## Example

```tsx
import { Combobox } from "@replicas/ui";

const statuses = ["Draft", "In review", "Approved", "Published", "Archived"];

export default function ComboboxDemo() {
  return (
    <Combobox.Root items={statuses} defaultValue="Draft">
      <Combobox.Trigger aria-label="Status">
        <Combobox.Value />
      </Combobox.Trigger>
      <Combobox.Popup aria-label="Change status">
        <Combobox.Input placeholder="Change status..." />
        <Combobox.Empty>No results</Combobox.Empty>
        <Combobox.List>
          {(status: string) => (
            <Combobox.Item key={status} value={status} shortcut={statuses.indexOf(status) + 1}>
              {status}
            </Combobox.Item>
          )}
        </Combobox.List>
      </Combobox.Popup>
    </Combobox.Root>
  );
}
```

## Foundations

The rest of the Palermo style, as a skill: https://replicas.raphaelsalaja.com/skills/palermo/SKILL.md