Menu
A list of actions in a dropdown, enhanced with keyboard navigation.
Partly measured from the menu CSS in the Cursor desktop app bundle. No reference has been captured yet.
import { Button, Menu } from "@replicas/ui";
export default function MenuDemo() {
return (
<Menu.Root>
<Menu.Trigger render={<Button>Account</Button>} />
<Menu.Popup>
<Menu.Item
shortcut={
<>
<Menu.Shortcut>⌘</Menu.Shortcut>
<Menu.Shortcut>,</Menu.Shortcut>
</>
}
>
Settings
</Menu.Item>
<Menu.Item>Invite members</Menu.Item>
<Menu.Separator />
<Menu.Item>Help and support</Menu.Item>
<Menu.Separator />
<Menu.Item>Switch account</Menu.Item>
<Menu.Item
shortcut={
<>
<Menu.Shortcut>⇧</Menu.Shortcut>
<Menu.Shortcut>⌘</Menu.Shortcut>
<Menu.Shortcut>Q</Menu.Shortcut>
</>
}
>
Log out
</Menu.Item>
</Menu.Popup>
</Menu.Root>
);
}Prompt
Copy Prompt hands your agent everything it needs to build the Menu in the Cursor style: the measured tokens, the CSS and the structure.
Show Prompt
# Cursor Menu
A list of actions in a dropdown, enhanced with keyboard navigation.
Build a Menu in this project that looks and behaves like Cursor's. Measured from the running Cursor app (cursor.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/menu) if it has none.
Fidelity: Partly measured from the menu CSS in the Cursor desktop app bundle. No reference has been captured yet.
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--cursor-icon-secondary` | `color-mix(in srgb, var(--cursor-base) 66%, transparent)` | `color-mix(in srgb, var(--cursor-base) 66%, transparent)` |
| `--text-quaternary` | `color-mix(in srgb, var(--cursor-base) 36%, transparent)` | `color-mix(in srgb, var(--cursor-base) 36%, transparent)` |
| `--surface-bg` | `oklch(1 0 0)` | `oklch(0.249 0 0)` |
| `--surface-border` | `color-mix(in srgb, var(--cursor-base) 12%, transparent)` | `color-mix(in srgb, var(--cursor-base) 12%, transparent)` |
| `--surface-divider` | `color-mix(in srgb, var(--cursor-base) 8%, transparent)` | `color-mix(in srgb, var(--cursor-base) 8%, transparent)` |
| `--surface-text` | `oklch(0.2264 0 0)` | `oklch(0.955 0 0)` |
| `--surface-text-strong` | `oklch(0.2264 0 0)` | `oklch(0.955 0 0)` |
| `--surface-text-muted` | `color-mix(in srgb, var(--cursor-base) 60%, transparent)` | `color-mix(in srgb, var(--cursor-base) 60%, transparent)` |
| `--surface-highlight` | `color-mix(in srgb, var(--cursor-base) 6%, transparent)` | `color-mix(in srgb, var(--cursor-base) 6%, transparent)` |
| `--shadow-menu` | `0 3px 8px 0 var(--cursor-shadow-secondary), 0 2px 5px 0 var(--cursor-shadow-secondary), 0 1px 1px 0 var(--cursor-shadow-secondary)` | `0 3px 8px 0 var(--cursor-shadow-secondary), 0 2px 5px 0 var(--cursor-shadow-secondary), 0 1px 1px 0 var(--cursor-shadow-secondary)` |
| `--font-regular` | `"SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif` | `"SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif` |
| `--font-size-small` | `0.8125rem` | `0.8125rem` |
| `--font-weight-normal` | `418` | `418` |
| `--radius-control` | `8px` | `8px` |
| `--radius-menu` | `14px` | `14px` |
| `--cursor-duration-fast` | `0.1s` | `0.1s` |
| `--ease-sharp` | `cubic-bezier(0.165, 0.84, 0.44, 1)` | `cubic-bezier(0.165, 0.84, 0.44, 1)` |
## CSS
Scoped under `[data-style="cursor"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.
```css
[data-style="cursor"] {
.ui-menu-positioner {
outline: none;
}
.ui-menu-popup {
box-sizing: border-box;
min-width: 200px;
max-width: 320px;
padding: 6px 0;
border-radius: var(--radius-menu);
background-color: var(--surface-bg);
box-shadow:
inset 0 0 0 1px var(--surface-border),
var(--shadow-menu);
color: var(--surface-text);
font-family: var(--font-regular);
font-size: var(--font-size-small);
line-height: 18px;
letter-spacing: -0.08px;
-webkit-font-smoothing: antialiased;
outline: none;
--ui-floating-anchor-offset-x: 0px;
--ui-floating-anchor-offset-y: 0px;
transform-origin: var(--transform-origin);
transition:
opacity var(--cursor-duration-fast) var(--ease-sharp),
transform var(--cursor-duration-fast) var(--ease-sharp);
&[data-side="top"] {
--ui-floating-anchor-offset-y: 2px;
}
&[data-side="bottom"] {
--ui-floating-anchor-offset-y: -2px;
}
&[data-side="left"] {
--ui-floating-anchor-offset-x: 2px;
}
&[data-side="right"] {
--ui-floating-anchor-offset-x: -2px;
}
&[data-starting-style],
&[data-ending-style] {
opacity: 0;
transform: translate3d(var(--ui-floating-anchor-offset-x), var(--ui-floating-anchor-offset-y), 0) scale(0.98);
}
}
.ui-menu-item {
position: relative;
isolation: isolate;
display: flex;
align-items: center;
gap: 10px;
min-height: 30px;
padding: 0 14px;
color: var(--surface-text);
cursor: default;
user-select: none;
outline: none;
&::before {
content: "";
position: absolute;
inset: 0 6px;
z-index: -1;
border-radius: var(--radius-control);
}
&[data-highlighted] {
color: var(--surface-text-strong);
&::before {
background-color: var(--surface-highlight);
}
}
&[data-disabled] {
color: var(--text-quaternary);
}
& svg {
width: 14px;
height: 14px;
flex-shrink: 0;
color: var(--cursor-icon-secondary);
}
}
.ui-menu-label {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: var(--font-weight-normal);
}
.ui-menu-shortcut {
display: inline-flex;
align-items: center;
gap: 2px;
margin-left: 20px;
font-size: var(--font-size-small);
font-weight: var(--font-weight-normal);
color: var(--surface-text-muted);
}
.ui-menu-key {
font-family: inherit;
font-size: var(--font-size-small);
font-weight: var(--font-weight-normal);
line-height: 18px;
color: var(--surface-text-muted);
}
.ui-menu-separator {
height: 1px;
margin: 6px 14px;
background-color: var(--surface-divider);
}
}
```
## Structure
How Replicas assembles it on Base UI.
```tsx
import { Menu as BaseMenu } from "@base-ui/react/menu";
import type { ComponentProps, ReactNode } from "react";
import { usePortalContainer } from "./portal";
const join = (base: string, extra?: string) => (extra ? `${base} ${extra}` : base);
type PopupProps = Omit<BaseMenu.Popup.Props, "className"> & {
className?: string;
side?: BaseMenu.Positioner.Props["side"];
align?: BaseMenu.Positioner.Props["align"];
sideOffset?: number;
};
function Popup({ className, side = "bottom", align = "start", sideOffset = 4, ...props }: PopupProps) {
return (
<BaseMenu.Portal container={usePortalContainer()}>
<BaseMenu.Positioner className="ui-menu-positioner" side={side} align={align} sideOffset={sideOffset}>
<BaseMenu.Popup className={join("ui-menu-popup", className)} {...props} />
</BaseMenu.Positioner>
</BaseMenu.Portal>
);
}
type ItemProps = Omit<BaseMenu.Item.Props, "className"> & {
className?: string;
shortcut?: ReactNode;
};
function Item({ className, shortcut, children, ...props }: ItemProps) {
return (
<BaseMenu.Item className={join("ui-menu-item", className)} {...props}>
<span className="ui-menu-label">{children}</span>
{shortcut ? <span className="ui-menu-shortcut">{shortcut}</span> : null}
</BaseMenu.Item>
);
}
function Separator({ className, ...props }: Omit<BaseMenu.Separator.Props, "className"> & { className?: string }) {
return <BaseMenu.Separator className={join("ui-menu-separator", className)} {...props} />;
}
function Shortcut({ className, ...props }: ComponentProps<"kbd">) {
return <kbd className={join("ui-menu-key", className)} {...props} />;
}
export const Menu = {
Root: BaseMenu.Root,
Trigger: BaseMenu.Trigger,
Popup,
Item,
Separator,
Shortcut,
};
```
## Example
```tsx
import { Button, Menu } from "@replicas/ui";
export default function MenuDemo() {
return (
<Menu.Root>
<Menu.Trigger render={<Button>Account</Button>} />
<Menu.Popup>
<Menu.Item
shortcut={
<>
<Menu.Shortcut>⌘</Menu.Shortcut>
<Menu.Shortcut>,</Menu.Shortcut>
</>
}
>
Settings
</Menu.Item>
<Menu.Item>Invite members</Menu.Item>
<Menu.Separator />
<Menu.Item>Help and support</Menu.Item>
<Menu.Separator />
<Menu.Item>Switch account</Menu.Item>
<Menu.Item
shortcut={
<>
<Menu.Shortcut>⇧</Menu.Shortcut>
<Menu.Shortcut>⌘</Menu.Shortcut>
<Menu.Shortcut>Q</Menu.Shortcut>
</>
}
>
Log out
</Menu.Item>
</Menu.Popup>
</Menu.Root>
);
}
```
## Foundations
The rest of the Cursor style, as a skill: https://replicas.raphaelsalaja.com/skills/cursor/SKILL.md