Overlay

Context Menu

Provides contextual actions for a specific target.

Imports

Use the same component slug for React, Vue, and style token lookup. Do not import components from package roots.

import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem } from "@line/abc-def-react/context-menu";
<script setup lang="ts">
import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem } from "@line/abc-def-vue/context-menu";
</script>

Shadcn references

Compare the corresponding shadcn React and Vue documentation for the same component slug.

Basic usage

Right click area
import {
  ContextMenu,
  ContextMenuContent,
  ContextMenuItem,
  ContextMenuTrigger,
} from "@line/abc-def-react/context-menu";

export function Example() {
  return (
    <ContextMenu>
      <ContextMenuTrigger>Right click area</ContextMenuTrigger>
      <ContextMenuContent>
        <ContextMenuItem>Copy token</ContextMenuItem>
      </ContextMenuContent>
    </ContextMenu>
  );
}
<script setup lang="ts">
import {
  ContextMenu,
  ContextMenuContent,
  ContextMenuItem,
  ContextMenuTrigger,
} from "@line/abc-def-vue/context-menu";
</script>

<template>
  <ContextMenu>
    <ContextMenuTrigger
      class="flex h-24 items-center justify-center rounded-md border text-sm"
    >
      Right click area
    </ContextMenuTrigger>
    <ContextMenuContent>
      <ContextMenuItem>Copy token</ContextMenuItem>
    </ContextMenuContent>
  </ContextMenu>
</template>

Component tokens

Component TokenSemantic TokenDefault Primitive Token
--context-menu-content-bg--popover--color-white
--context-menu-content-fg--popover-foreground--color-zinc-950
--context-menu-content-border--foreground--color-zinc-950
--context-menu-label-fg--muted-foreground--color-zinc-500
--context-menu-item-bg-focus--accent--color-zinc-100
--context-menu-item-fg-focus--accent-foreground--color-zinc-900
--context-menu-item-fg-destructive--destructive--color-red-50
--context-menu-item-bg-destructive-focus--destructive--color-red-50
--context-menu-item-fg-destructive-focus--destructive--color-red-50
--context-menu-sub-trigger-bg-focus--accent--color-zinc-100
--context-menu-sub-trigger-fg-focus--accent-foreground--color-zinc-900
--context-menu-separator-bg--border--color-zinc-200
--context-menu-shortcut-fg--muted-foreground--color-zinc-500
--context-menu-shortcut-fg-focus--accent-foreground--color-zinc-900

Composition exports

ContextMenuContextMenuTriggerContextMenuContentContextMenuItem

Usage notes

  • Mirror essential actions elsewhere for touch and keyboard users.
  • Keep destructive actions visually distinct.
  • Related component tokens use the `context-menu` token group in `@line/abc-def-styles/css`.