import { Button, CommandPalette, Kbd } from "@replicas/ui";
import { useState } from "react";

type Item = { value: string; label: string; shortcut?: string };
type Group = { value: string; items: Item[] };

const groups: Group[] = [
  {
    value: "Actions",
    items: [
      { value: "new-file", label: "New file", shortcut: "N" },
      { value: "upload", label: "Upload file", shortcut: "U" },
      { value: "invite", label: "Invite members", shortcut: "I" },
    ],
  },
  {
    value: "Navigation",
    items: [
      { value: "home", label: "Go to home", shortcut: "G H" },
      { value: "recent", label: "Go to recent", shortcut: "G R" },
      { value: "settings", label: "Open settings", shortcut: "G S" },
    ],
  },
];

export default function CommandPaletteDemo() {
  const [open, setOpen] = useState(false);

  return (
    <CommandPalette.Root open={open} onOpenChange={setOpen}>
      <CommandPalette.Trigger render={<Button />}>
        Open command menu <Kbd>⌘K</Kbd>
      </CommandPalette.Trigger>
      <CommandPalette.Popup items={groups}>
        <CommandPalette.Input placeholder="Type a command or search…" />
        <CommandPalette.Empty>No results</CommandPalette.Empty>
        <CommandPalette.List>
          {(group: Group) => (
            <CommandPalette.Group key={group.value} items={group.items}>
              <CommandPalette.GroupLabel>{group.value}</CommandPalette.GroupLabel>
              <CommandPalette.Collection>
                {(item: Item) => (
                  <CommandPalette.Item
                    key={item.value}
                    value={item}
                    shortcut={item.shortcut}
                    onClick={() => setOpen(false)}
                  >
                    {item.label}
                  </CommandPalette.Item>
                )}
              </CommandPalette.Collection>
            </CommandPalette.Group>
          )}
        </CommandPalette.List>
      </CommandPalette.Popup>
    </CommandPalette.Root>
  );
}

Prompt

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

Show Prompt
# Shopify Command Palette

A searchable list of actions in a dialog, opened from anywhere.

Build a Command Palette in this project that looks and behaves like Shopify's. Measured from the running Shopify app (admin.shopify.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 primitives if it has none.

Fidelity: Measured from Shopify admin search (sidebar Search, also ⌘K). The panel is measured: 648px wide, 24px corners, the dialog shadow, no transition and the 71% black backdrop. The full-width search field and footer follow the measured admin layout. Result rows reuse the measured action list items because an empty store shows no results.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--p-border-radius-100` | `.25rem` | `.25rem` |
| `--p-border-radius-corner-shape` | `superellipse(1.333)` | `superellipse(1.333)` |
| `--p-border-radius-dialog` | `1.5rem` | `1.5rem` |
| `--p-border-radius-option-item` | `.75rem` | `.75rem` |
| `--p-border-width-025` | `.0625rem` | `.0625rem` |
| `--p-color-backdrop-bg` | `#000000b5` | `#000000b5` |
| `--p-color-bg-surface` | `#fff` | `#1a1a1a` |
| `--p-color-bg-surface-active` | `#f2f2f2` | `#282828` |
| `--p-color-bg-surface-hover` | `#f7f7f7` | `#222` |
| `--p-color-bg-surface-tertiary` | `#f2f2f2` | `#2f2f2f` |
| `--p-color-border-secondary` | `rgba(242,242,242,1)` | `#ffffff0f` |
| `--p-color-icon` | `#101010` | `#dcdcdc` |
| `--p-color-icon-secondary` | `#606060` | `#aaa` |
| `--p-color-text` | `#101010` | `#eee` |
| `--p-color-text-disabled` | `#a6a6a6` | `#585858` |
| `--p-color-text-secondary` | `rgba(74,74,74,1)` | `#aaa` |
| `--p-font-family-sans` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` |
| `--p-font-letter-spacing-body-medium` | `-.01em` | `-.01em` |
| `--p-font-line-height-body-medium` | `1.25rem` | `1.25rem` |
| `--p-font-line-height-body-small` | `1.125rem` | `1.125rem` |
| `--p-font-size-300` | `.75rem` | `.75rem` |
| `--p-font-size-400` | `1rem` | `1rem` |
| `--p-font-size-body-medium` | `.8125rem` | `.8125rem` |
| `--p-font-size-body-small` | `.75rem` | `.75rem` |
| `--p-font-weight-medium` | `500` | `500` |
| `--p-height-700` | `1.75rem` | `1.75rem` |
| `--p-height-800` | `2rem` | `2rem` |
| `--p-shadow-dialog` | `0rem .125rem .1875rem -.0625rem rgba(0,0,0,.06), 0rem .25rem .375rem -.125rem #0000000f, 0rem .5rem .75rem -.25rem #0000000f, 0rem 1rem 1.5rem -.375rem #0000000f, 0rem 2rem 3rem -.5rem #0000000f, 0rem 0rem 0rem .0625rem #00000014` | `0rem 0rem 0rem .0625rem #dcdcdc2e, 0rem .0625rem .125rem 0rem #00000026, 0rem .1875rem .375rem -.1875rem #0000003d, 0rem 1.25rem 2rem -.75rem #00000099` |
| `--p-space-050` | `.125rem` | `.125rem` |
| `--p-space-100` | `.25rem` | `.25rem` |
| `--p-space-150` | `.375rem` | `.375rem` |
| `--p-space-200` | `.5rem` | `.5rem` |
| `--p-space-300` | `.75rem` | `.75rem` |
| `--p-space-500` | `1.25rem` | `1.25rem` |
| `--p-space-1000` | `2.5rem` | `2.5rem` |

## CSS

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

```css
[data-style="shopify"] {
  .ui-command-palette-backdrop {
    position: fixed;
    inset: 0;
    background-color: var(--p-color-backdrop-bg);
  }

  .ui-command-palette-viewport {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 120px var(--p-space-300);
  }

  .ui-command-palette {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: 648px;
    max-width: 100%;
    min-height: 100px;
    max-height: min(480px, calc(100dvh - 240px));
    overflow: hidden;
    border-radius: var(--p-border-radius-dialog);
    corner-shape: var(--p-border-radius-corner-shape);
    background-color: var(--p-color-bg-surface);
    box-shadow: var(--p-shadow-dialog);
    color: var(--p-color-text);
    font-family: var(--p-font-family-sans);
    font-size: var(--p-font-size-body-medium);
    line-height: var(--p-font-line-height-body-medium);
    letter-spacing: var(--p-font-letter-spacing-body-medium);
    outline: none;
  }

  .ui-command-palette-input-group {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: var(--p-space-200);
    min-height: 40px;
    padding: var(--p-space-300) var(--p-space-1000) var(--p-space-200) var(--p-space-300);
    border-bottom: var(--p-border-width-025) solid var(--p-color-border-secondary);
    background-color: var(--p-color-bg-surface);
  }

  .ui-command-palette-search {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--p-color-icon);

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

  .ui-command-palette-input {
    box-sizing: border-box;
    flex: 1;
    min-width: 0;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    background-color: transparent;
    color: var(--p-color-text);
    font-family: inherit;
    font-size: var(--p-font-size-body-medium);
    letter-spacing: inherit;
    outline: none;

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

  .ui-command-palette-list {
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
    padding: var(--p-space-200);
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-block: var(--p-space-200);
    outline: none;
  }

  .ui-command-palette-group + .ui-command-palette-group {
    margin-top: var(--p-space-200);
  }

  .ui-command-palette-group-label {
    display: flex;
    align-items: center;
    min-height: var(--p-height-700);
    padding: 0 var(--p-space-200);
    color: var(--p-color-text-secondary);
    font-size: var(--p-font-size-body-small);
    font-weight: var(--p-font-weight-medium);
    line-height: var(--p-font-line-height-body-small);
  }

  .ui-command-palette-item {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: var(--p-space-150);
    min-height: var(--p-height-800);
    padding: var(--p-space-100) var(--p-space-200);
    border-radius: var(--p-border-radius-option-item);
    color: var(--p-color-text);
    cursor: pointer;
    user-select: none;
    outline: none;

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

    &:active {
      background-color: var(--p-color-bg-surface-active);
    }

    &[data-disabled] {
      color: var(--p-color-text-disabled);
      cursor: default;
    }
  }

  .ui-command-palette-icon {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--p-color-icon-secondary);

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

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

  .ui-command-palette-shortcut {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: var(--p-space-050);
    color: var(--p-color-text-secondary);
    font-size: var(--p-font-size-300);
    font-weight: var(--p-font-weight-medium);
    line-height: var(--p-font-size-400);
    white-space: pre;

    & kbd {
      box-sizing: border-box;
      min-width: var(--p-space-500);
      height: var(--p-space-500);
      padding: var(--p-space-050) var(--p-space-100);
      border-radius: var(--p-border-radius-100);
      background-color: var(--p-color-bg-surface-tertiary);
      font: inherit;
      text-align: center;
    }
  }

  .ui-command-palette-empty:not(:empty) {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    margin: 0 var(--p-space-200) var(--p-space-200);
    color: var(--p-color-text-secondary);
  }

  .ui-command-palette-footer {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-end;
    gap: var(--p-space-300);
    min-height: 48px;
    padding: var(--p-space-200) var(--p-space-300);
    border-top: var(--p-border-width-025) solid var(--p-color-border-secondary);
    background-color: var(--p-color-bg-surface);
    color: var(--p-color-text-secondary);
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Autocomplete as BaseAutocomplete } from "@base-ui/react/autocomplete";
import { Dialog as BaseDialog } from "@base-ui/react/dialog";
import type { ComponentProps, ReactNode } from "react";
import { usePortalContainer } from "./portal";
import { join } from "./utils";

type PopupProps = Omit<BaseAutocomplete.Root.Props<unknown>, "open" | "inline" | "children"> & {
  className?: string;
  label?: string;
  children?: ReactNode;
};

function Popup({ className, label = "Command palette", children, ...props }: PopupProps) {
  return (
    <BaseDialog.Portal container={usePortalContainer()}>
      <BaseDialog.Backdrop className="ui-command-palette-backdrop" />
      <BaseDialog.Viewport className="ui-command-palette-viewport">
        <BaseDialog.Popup className={join("ui-command-palette", className)} aria-label={label}>
          <BaseAutocomplete.Root open inline autoHighlight="always" keepHighlight {...props}>
            {children}
          </BaseAutocomplete.Root>
        </BaseDialog.Popup>
      </BaseDialog.Viewport>
    </BaseDialog.Portal>
  );
}

function Input({ className, ...props }: Omit<BaseAutocomplete.Input.Props, "className"> & { className?: string }) {
  return (
    <BaseAutocomplete.InputGroup className="ui-command-palette-input-group">
      <svg className="ui-command-palette-search" viewBox="0 0 16 16" fill="none" aria-hidden>
        <circle cx="7" cy="7" r="4.5" stroke="currentColor" strokeWidth="1.5" />
        <path d="M10.5 10.5L13.5 13.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
      </svg>
      <BaseAutocomplete.Input className={join("ui-command-palette-input", className)} {...props} />
    </BaseAutocomplete.InputGroup>
  );
}

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

function Group({ className, ...props }: Omit<BaseAutocomplete.Group.Props, "className"> & { className?: string }) {
  return <BaseAutocomplete.Group className={join("ui-command-palette-group", className)} {...props} />;
}

function GroupLabel({
  className,
  ...props
}: Omit<BaseAutocomplete.GroupLabel.Props, "className"> & { className?: string }) {
  return <BaseAutocomplete.GroupLabel className={join("ui-command-palette-group-label", className)} {...props} />;
}

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

function Item({ className, icon, shortcut, children, ...props }: ItemProps) {
  return (
    <BaseAutocomplete.Item className={join("ui-command-palette-item", className)} {...props}>
      {icon !== undefined ? <span className="ui-command-palette-icon">{icon}</span> : null}
      <span className="ui-command-palette-label">{children}</span>
      {shortcut !== undefined ? <span className="ui-command-palette-shortcut">{shortcut}</span> : null}
    </BaseAutocomplete.Item>
  );
}

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

function Footer({ className, ...props }: ComponentProps<"div">) {
  return <div className={join("ui-command-palette-footer", className)} {...props} />;
}

export const CommandPalette = {
  Root: BaseDialog.Root,
  Trigger: BaseDialog.Trigger,
  Close: BaseDialog.Close,
  Popup,
  Input,
  List,
  Group,
  GroupLabel,
  Collection: BaseAutocomplete.Collection,
  Item,
  Empty,
  Footer,
};
```

## Example

```tsx
import { Button, CommandPalette, Kbd } from "@replicas/ui";
import { useState } from "react";

type Item = { value: string; label: string; shortcut?: string };
type Group = { value: string; items: Item[] };

const groups: Group[] = [
  {
    value: "Actions",
    items: [
      { value: "new-file", label: "New file", shortcut: "N" },
      { value: "upload", label: "Upload file", shortcut: "U" },
      { value: "invite", label: "Invite members", shortcut: "I" },
    ],
  },
  {
    value: "Navigation",
    items: [
      { value: "home", label: "Go to home", shortcut: "G H" },
      { value: "recent", label: "Go to recent", shortcut: "G R" },
      { value: "settings", label: "Open settings", shortcut: "G S" },
    ],
  },
];

export default function CommandPaletteDemo() {
  const [open, setOpen] = useState(false);

  return (
    <CommandPalette.Root open={open} onOpenChange={setOpen}>
      <CommandPalette.Trigger render={<Button />}>
        Open command menu <Kbd>⌘K</Kbd>
      </CommandPalette.Trigger>
      <CommandPalette.Popup items={groups}>
        <CommandPalette.Input placeholder="Type a command or search…" />
        <CommandPalette.Empty>No results</CommandPalette.Empty>
        <CommandPalette.List>
          {(group: Group) => (
            <CommandPalette.Group key={group.value} items={group.items}>
              <CommandPalette.GroupLabel>{group.value}</CommandPalette.GroupLabel>
              <CommandPalette.Collection>
                {(item: Item) => (
                  <CommandPalette.Item
                    key={item.value}
                    value={item}
                    shortcut={item.shortcut}
                    onClick={() => setOpen(false)}
                  >
                    {item.label}
                  </CommandPalette.Item>
                )}
              </CommandPalette.Collection>
            </CommandPalette.Group>
          )}
        </CommandPalette.List>
      </CommandPalette.Popup>
    </CommandPalette.Root>
  );
}
```

## Foundations

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