Context Menu Primitive
Use Context Menu to offer actions for a specific item, such as renaming a file. It opens at the point where the person requests the menu.
Anatomy
Use the Astro primitive adapter to render ContextMenu anatomy with the Runtime wiring included.
---import { ContextMenu } from "@starwind-ui/astro/context-menu";---
<ContextMenu.Root> <ContextMenu.Trigger>Right click</ContextMenu.Trigger> <ContextMenu.Positioner> <ContextMenu.Popup> <ContextMenu.Item>Copy</ContextMenu.Item> </ContextMenu.Popup> </ContextMenu.Positioner></ContextMenu.Root>Use the React primitive adapter when ContextMenu state participates in React rendering.
import { ContextMenu } from "@starwind-ui/react/context-menu";
export function Example() { return ( <ContextMenu.Root> <ContextMenu.Trigger>Right click</ContextMenu.Trigger> <ContextMenu.Positioner> <ContextMenu.Popup> <ContextMenu.Item>Copy</ContextMenu.Item> </ContextMenu.Popup> </ContextMenu.Positioner> </ContextMenu.Root> );}Use the Vue components to build ContextMenu.
<script setup lang="ts">import ContextMenu from "@starwind-ui/vue/context-menu";</script>
<template> <ContextMenu.Root> <ContextMenu.Trigger>Right click</ContextMenu.Trigger> <ContextMenu.Positioner> <ContextMenu.Popup> <ContextMenu.Item>Copy</ContextMenu.Item> </ContextMenu.Popup> </ContextMenu.Positioner> </ContextMenu.Root></template>Use the Svelte components to build ContextMenu.
<script lang="ts"> import { ContextMenu } from "@starwind-ui/svelte/context-menu";</script>
<ContextMenu.Root> <ContextMenu.Trigger>Right click</ContextMenu.Trigger> <ContextMenu.Positioner> <ContextMenu.Popup> <ContextMenu.Item>Copy</ContextMenu.Item> </ContextMenu.Popup> </ContextMenu.Positioner></ContextMenu.Root>Render the ContextMenu data-sw-* contract yourself, then initialize createContextMenu.
<div data-sw-context-menu data-sw-menu=""> <div data-sw-context-menu-trigger data-sw-menu-trigger="" aria-haspopup="menu">Right click</div> <div data-sw-menu-positioner> <div data-sw-menu-popup role="menu" tabindex="-1" hidden> <div data-sw-menu-item role="menuitem" tabindex="0">Copy</div> </div> </div></div>
<script type="module"> import { createContextMenu } from "@starwind-ui/runtime/context-menu";
const root = document.querySelector("[data-sw-context-menu]"); if (root) { createContextMenu(root); }</script>Astro, React, Vue, and Svelte components use the same underlying interactions. Each framework has its own way to read and update state. See the examples and your installed packageโs types for the available props and events. Plain HTML uses DOM events and Runtime methods.
Floating Behavior
| Fact | Value |
|---|---|
| Anchor part | anchor |
| Positioner part | positioner |
| Popup part | popup |
| Portal part | portal |
| Option props | side, align, sideOffset, avoidCollisions |
API Reference
Root
The main element that owns the Context Menu Runtime instance.
- Default element
- div
- Discovery hook
- data-sw-context-menu
- Role
- -
Props
open boolean -
- Description
- Controls whether Context Menu is open.
- Kind
- control
- Targets
- root
- Full type
- boolean
- React
Use open for controlled state and defaultOpen for default state, and onOpenChange for change proposals.
opendefaultOpenonOpenChange
- Astro
Use open or defaultOpen for initial state, listen for starwind:open-change, and call setOpen for later updates.
opendefaultOpenstarwind:open-changesetOpen
- Runtime / HTML
Use data-default-open for initial state, listen for starwind:open-change, and call setOpen for later updates.
data-default-openstarwind:open-changesetOpen
defaultOpen boolean false
- Description
- Sets whether Context Menu starts open.
- Kind
- control
- Targets
- root
- Full type
- boolean
- React
Use open for controlled state and defaultOpen for default state, and onOpenChange for change proposals.
opendefaultOpenonOpenChange
- Astro
Use open or defaultOpen for initial state, listen for starwind:open-change, and call setOpen for later updates.
opendefaultOpenstarwind:open-changesetOpen
- Runtime / HTML
Use data-default-open for initial state, listen for starwind:open-change, and call setOpen for later updates.
data-default-openstarwind:open-changesetOpen
disabled boolean false
- Description
- Disables the Root part.
- Kind
- option
- Targets
- root, trigger, item, linkItem, checkboxItem, radioItem, submenuTrigger
- Full type
- boolean
modal boolean true
- Description
- Makes Context Menu behave as a modal overlay.
- Kind
- option
- Targets
- root
- Full type
- boolean
closeDelay number 200
- Description
- Sets how long Context Menu waits before closing.
- Kind
- option
- Targets
- root, submenuRoot
- Full type
- number
onCloseComplete (open: boolean, details: ContextMenuCloseCompleteDetails) => void -
- Description
- Runs after Context Menu has finished closing.
- Kind
- callback
- Targets
- root
- Full type
- (open: boolean, details: ContextMenuCloseCompleteDetails) => void
onOpenChange (open: boolean, details: ContextMenuOpenChangeDetails) => void -
- Description
- Runs when Context Menu opens or closes.
- Kind
- callback
- Targets
- root
- Full type
- (open: boolean, details: ContextMenuOpenChangeDetails) => void
- React
Use open for controlled state and defaultOpen for default state, and onOpenChange for change proposals.
opendefaultOpenonOpenChange
- Astro
Use open or defaultOpen for initial state, listen for starwind:open-change, and call setOpen for later updates.
opendefaultOpenstarwind:open-changesetOpen
- Runtime / HTML
Use data-default-open for initial state, listen for starwind:open-change, and call setOpen for later updates.
data-default-openstarwind:open-changesetOpen
Events
openChange onOpenChange open: boolean
- Description
- Fires when Context Menu opens or closes.
- DOM event
- starwind:open-change
- Details type
- ContextMenuOpenChangeDetails
- Timing
- before-state-commit
- Cancelable
- Yes
- Cancellation sequence
- Check internal eligibility and intent.
- Create one details object for the proposal.
- Call the Runtime callback with the details object when the controller exposes one.
- Dispatch the cancelable DOM event with the same details object, including when the callback canceled it.
- Read details.isCanceled, including cancellation caused by preventDefault().
- Apply the accepted state.
- Notify Runtime subscribers and other accepted-only observers.
closeComplete onCloseComplete open: boolean
- Description
- Fires after Context Menu has finished closing.
- DOM event
- starwind:close-complete
- Details type
- ContextMenuCloseCompleteDetails
- Timing
- after-state-commit
- Cancelable
- No
State
open boolean open / defaultOpen
- Description
- Tracks whether Context Menu is open.
- Initial attribute
- data-default-open
- Runtime getter
- getOpen
- Runtime setter
- setOpen
- React
Use open for controlled state and defaultOpen for default state, and onOpenChange for change proposals.
opendefaultOpenonOpenChange
- Astro
Use open or defaultOpen for initial state, listen for starwind:open-change, and call setOpen for later updates.
opendefaultOpenstarwind:open-changesetOpen
- Runtime / HTML
Use data-default-open for initial state, listen for starwind:open-change, and call setOpen for later updates.
data-default-openstarwind:open-changesetOpen
checked boolean checked / defaultChecked
- Description
- Tracks whether Context Menu is checked.
- Initial attribute
- data-default-checked
- Runtime getter
- -
- Runtime setter
- -
- React
Use checked for controlled state and defaultChecked for default state, and onCheckedChange for change proposals.
checkeddefaultCheckedonCheckedChange
- Astro
Use checked or defaultChecked for initial state and listen for starwind:checked-change.
checkeddefaultCheckedstarwind:checked-change
- Runtime / HTML
Use data-default-checked for initial state and listen for starwind:checked-change.
data-default-checkedstarwind:checked-change
radioValue string value / defaultValue
- Description
- Tracks the selected radio value for Context Menu.
- Initial attribute
- data-value
- Runtime getter
- -
- Runtime setter
- -
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state and listen for starwind:value-change.
valuedefaultValuestarwind:value-change
- Runtime / HTML
Use data-value for initial state and listen for starwind:value-change.
data-valuestarwind:value-change
Data Attributes
Runtime hooks
State
Metadata
Trigger
The control that opens, closes, or targets the Context Menu content.
- Default element
- div
- Discovery hook
- data-sw-context-menu-trigger
- Role
- -
Props
disabled boolean false
- Description
- Disables the Trigger part.
- Kind
- option
- Targets
- root, trigger, item, linkItem, checkboxItem, radioItem, submenuTrigger
- Full type
- boolean
Data Attributes
Runtime hooks
State
Metadata
Anchor
The virtual anchor used to position Context Menu content.
- Default element
- span
- Discovery hook
- data-sw-context-menu-anchor
- Role
- -
Data Attributes
Runtime hooks
Portal
Moves Context Menu overlay content to the document body when needed.
- Default element
- div
- Discovery hook
- data-sw-menu-portal
- Role
- -
Data Attributes
Runtime hooks
Metadata
Positioner
Positions the Context Menu content relative to its trigger.
- Default element
- div
- Discovery hook
- data-sw-menu-positioner
- Role
- -
Props
side "top" | "right" | "bottom" | "left" "bottom"
- Description
- Sets the preferred side for Context Menu content.
- Kind
- option
- Targets
- positioner, popup
- Full type
- "top" | "right" | "bottom" | "left"
align "start" | "center" | "end" "start"
- Description
- Sets how Context Menu content aligns to its trigger.
- Kind
- option
- Targets
- positioner, popup
- Full type
- "start" | "center" | "end"
sideOffset number 4
- Description
- Sets the distance between Context Menu content and its trigger.
- Kind
- option
- Targets
- positioner, popup
- Full type
- number
avoidCollisions boolean true
- Description
- Allows Context Menu content to shift or flip to stay visible.
- Kind
- option
- Targets
- positioner, popup
- Full type
- boolean
Data Attributes
Runtime hooks
State
Metadata
Popup
The floating content container for Context Menu.
- Default element
- div
- Discovery hook
- data-sw-menu-popup
- Role
- menu
Props
side "top" | "right" | "bottom" | "left" "bottom"
- Description
- Sets the preferred side for Context Menu content.
- Kind
- option
- Targets
- positioner, popup
- Full type
- "top" | "right" | "bottom" | "left"
align "start" | "center" | "end" "start"
- Description
- Sets how Context Menu content aligns to its trigger.
- Kind
- option
- Targets
- positioner, popup
- Full type
- "start" | "center" | "end"
sideOffset number 4
- Description
- Sets the distance between Context Menu content and its trigger.
- Kind
- option
- Targets
- positioner, popup
- Full type
- number
avoidCollisions boolean true
- Description
- Allows Context Menu content to shift or flip to stay visible.
- Kind
- option
- Targets
- positioner, popup
- Full type
- boolean
Data Attributes
Runtime hooks
State
Metadata
Item
An interactive item inside the Context Menu collection.
- Default element
- div
- Discovery hook
- data-sw-menu-item
- Role
- menuitem
Props
disabled boolean false
- Description
- Disables the Item part.
- Kind
- option
- Targets
- root, trigger, item, linkItem, checkboxItem, radioItem, submenuTrigger
- Full type
- boolean
closeOnClick boolean true
- Description
- Closes Context Menu after the item is clicked.
- Kind
- option
- Targets
- item
- Full type
- boolean
Data Attributes
Runtime hooks
Metadata
Link Item
A link-style item inside the Context Menu collection.
- Default element
- a
- Discovery hook
- data-sw-menu-link-item
- Role
- menuitem
Props
disabled boolean false
- Description
- Disables the Link Item part.
- Kind
- option
- Targets
- root, trigger, item, linkItem, checkboxItem, radioItem, submenuTrigger
- Full type
- boolean
closeOnClick boolean false
- Description
- Closes Context Menu after the item is clicked.
- Kind
- option
- Targets
- linkItem
- Full type
- boolean
Data Attributes
Runtime hooks
Metadata
Checkbox Item
A checkbox-style item inside the Context Menu collection.
- Default element
- div
- Discovery hook
- data-sw-menu-checkbox-item
- Role
- menuitemcheckbox
Props
disabled boolean false
- Description
- Disables the Checkbox Item part.
- Kind
- option
- Targets
- root, trigger, item, linkItem, checkboxItem, radioItem, submenuTrigger
- Full type
- boolean
checked boolean -
- Description
- Controls whether Context Menu is checked.
- Kind
- control
- Targets
- checkboxItem, radioItem
- Full type
- boolean
- React
Use checked for controlled state and defaultChecked for default state, and onCheckedChange for change proposals.
checkeddefaultCheckedonCheckedChange
- Astro
Use checked or defaultChecked for initial state and listen for starwind:checked-change.
checkeddefaultCheckedstarwind:checked-change
- Runtime / HTML
Use data-default-checked for initial state and listen for starwind:checked-change.
data-default-checkedstarwind:checked-change
defaultChecked boolean false
- Description
- Sets whether Context Menu starts checked for uncontrolled usage.
- Kind
- control
- Targets
- checkboxItem, radioItem
- Full type
- boolean
- React
Use checked for controlled state and defaultChecked for default state, and onCheckedChange for change proposals.
checkeddefaultCheckedonCheckedChange
- Astro
Use checked or defaultChecked for initial state and listen for starwind:checked-change.
checkeddefaultCheckedstarwind:checked-change
- Runtime / HTML
Use data-default-checked for initial state and listen for starwind:checked-change.
data-default-checkedstarwind:checked-change
closeOnClick boolean false
- Description
- Closes Context Menu after the item is clicked.
- Kind
- option
- Targets
- checkboxItem, radioItem
- Full type
- boolean
onCheckedChange (checked: boolean, details: MenuCheckedChangeDetails) => void -
- Description
- Runs when the Context Menu checked state changes.
- Kind
- callback
- Targets
- checkboxItem
- Full type
- (checked: boolean, details: MenuCheckedChangeDetails) => void
- React
Use checked for controlled state and defaultChecked for default state, and onCheckedChange for change proposals.
checkeddefaultCheckedonCheckedChange
- Astro
Use checked or defaultChecked for initial state and listen for starwind:checked-change.
checkeddefaultCheckedstarwind:checked-change
- Runtime / HTML
Use data-default-checked for initial state and listen for starwind:checked-change.
data-default-checkedstarwind:checked-change
Events
checkedChange onCheckedChange checked: boolean
- Description
- Fires when the checked state changes for Context Menu.
- DOM event
- starwind:checked-change
- Details type
- MenuCheckedChangeDetails
- Timing
- before-state-commit
- Cancelable
- Yes
- Cancellation sequence
- Check internal eligibility and intent.
- Create one details object for the proposal.
- Call the Runtime callback with the details object when the controller exposes one.
- Dispatch the cancelable DOM event with the same details object, including when the callback canceled it.
- Read details.isCanceled, including cancellation caused by preventDefault().
- Apply the accepted state.
- Notify Runtime subscribers and other accepted-only observers.
State
checked boolean checked / defaultChecked
- Description
- Tracks whether Context Menu is checked.
- Initial attribute
- data-default-checked
- Runtime getter
- -
- Runtime setter
- -
- React
Use checked for controlled state and defaultChecked for default state, and onCheckedChange for change proposals.
checkeddefaultCheckedonCheckedChange
- Astro
Use checked or defaultChecked for initial state and listen for starwind:checked-change.
checkeddefaultCheckedstarwind:checked-change
- Runtime / HTML
Use data-default-checked for initial state and listen for starwind:checked-change.
data-default-checkedstarwind:checked-change
Data Attributes
Runtime hooks
State
Metadata
Checkbox Item Indicator
Shows the checked state for a Context Menu checkbox item.
- Default element
- span
- Discovery hook
- data-sw-menu-checkbox-item-indicator
- Role
- -
Data Attributes
Runtime hooks
State
Radio Group
Groups related radio items inside Context Menu.
- Default element
- div
- Discovery hook
- data-sw-menu-radio-group
- Role
- group
Props
value string -
- Description
- Controls the current Context Menu value.
- Kind
- control
- Targets
- radioGroup
- Full type
- string
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state and listen for starwind:value-change.
valuedefaultValuestarwind:value-change
- Runtime / HTML
Use data-value for initial state and listen for starwind:value-change.
data-valuestarwind:value-change
defaultValue string -
- Description
- Sets the initial Context Menu value for uncontrolled usage.
- Kind
- control
- Targets
- radioGroup
- Full type
- string
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state and listen for starwind:value-change.
valuedefaultValuestarwind:value-change
- Runtime / HTML
Use data-value for initial state and listen for starwind:value-change.
data-valuestarwind:value-change
onValueChange (value: string, details: MenuValueChangeDetails) => void -
- Description
- Runs when the Context Menu value changes.
- Kind
- callback
- Targets
- radioGroup
- Full type
- (value: string, details: MenuValueChangeDetails) => void
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state and listen for starwind:value-change.
valuedefaultValuestarwind:value-change
- Runtime / HTML
Use data-value for initial state and listen for starwind:value-change.
data-valuestarwind:value-change
Events
valueChange onValueChange value: string
- Description
- Fires when the value changes for Context Menu.
- DOM event
- starwind:value-change
- Details type
- MenuValueChangeDetails
- Timing
- before-state-commit
- Cancelable
- Yes
- Cancellation sequence
- Check internal eligibility and intent.
- Create one details object for the proposal.
- Call the Runtime callback with the details object when the controller exposes one.
- Dispatch the cancelable DOM event with the same details object, including when the callback canceled it.
- Read details.isCanceled, including cancellation caused by preventDefault().
- Apply the accepted state.
- Notify Runtime subscribers and other accepted-only observers.
State
radioValue string value / defaultValue
- Description
- Tracks the selected radio value for Context Menu.
- Initial attribute
- data-value
- Runtime getter
- -
- Runtime setter
- -
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state and listen for starwind:value-change.
valuedefaultValuestarwind:value-change
- Runtime / HTML
Use data-value for initial state and listen for starwind:value-change.
data-valuestarwind:value-change
Data Attributes
Runtime hooks
State
Radio Item
A radio-style item inside the Context Menu collection.
- Default element
- div
- Discovery hook
- data-sw-menu-radio-item
- Role
- menuitemradio
Props
disabled boolean false
- Description
- Disables the Radio Item part.
- Kind
- option
- Targets
- root, trigger, item, linkItem, checkboxItem, radioItem, submenuTrigger
- Full type
- boolean
checked boolean -
- Description
- Controls whether Context Menu is checked.
- Kind
- control
- Targets
- checkboxItem, radioItem
- Full type
- boolean
- React
Use checked for controlled state and defaultChecked for default state, and onCheckedChange for change proposals.
checkeddefaultCheckedonCheckedChange
- Astro
Use checked or defaultChecked for initial state and listen for starwind:checked-change.
checkeddefaultCheckedstarwind:checked-change
- Runtime / HTML
Use data-default-checked for initial state and listen for starwind:checked-change.
data-default-checkedstarwind:checked-change
defaultChecked boolean false
- Description
- Sets whether Context Menu starts checked for uncontrolled usage.
- Kind
- control
- Targets
- checkboxItem, radioItem
- Full type
- boolean
- React
Use checked for controlled state and defaultChecked for default state, and onCheckedChange for change proposals.
checkeddefaultCheckedonCheckedChange
- Astro
Use checked or defaultChecked for initial state and listen for starwind:checked-change.
checkeddefaultCheckedstarwind:checked-change
- Runtime / HTML
Use data-default-checked for initial state and listen for starwind:checked-change.
data-default-checkedstarwind:checked-change
closeOnClick boolean false
- Description
- Closes Context Menu after the item is clicked.
- Kind
- option
- Targets
- checkboxItem, radioItem
- Full type
- boolean
value string -
- Description
- Controls the current Context Menu value.
- Kind
- option
- Targets
- radioItem
- Full type
- string
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state and listen for starwind:value-change.
valuedefaultValuestarwind:value-change
- Runtime / HTML
Use data-value for initial state and listen for starwind:value-change.
data-valuestarwind:value-change
State
checked boolean checked / defaultChecked
- Description
- Tracks whether Context Menu is checked.
- Initial attribute
- data-default-checked
- Runtime getter
- -
- Runtime setter
- -
- React
Use checked for controlled state and defaultChecked for default state, and onCheckedChange for change proposals.
checkeddefaultCheckedonCheckedChange
- Astro
Use checked or defaultChecked for initial state and listen for starwind:checked-change.
checkeddefaultCheckedstarwind:checked-change
- Runtime / HTML
Use data-default-checked for initial state and listen for starwind:checked-change.
data-default-checkedstarwind:checked-change
radioValue string value / defaultValue
- Description
- Tracks the selected radio value for Context Menu.
- Initial attribute
- data-value
- Runtime getter
- -
- Runtime setter
- -
- React
Use value for controlled state and defaultValue for default state, and onValueChange for change proposals.
valuedefaultValueonValueChange
- Astro
Use value or defaultValue for initial state and listen for starwind:value-change.
valuedefaultValuestarwind:value-change
- Runtime / HTML
Use data-value for initial state and listen for starwind:value-change.
data-valuestarwind:value-change
Data Attributes
Runtime hooks
State
Metadata
Radio Item Indicator
Shows the selected state for a Context Menu radio item.
- Default element
- span
- Discovery hook
- data-sw-menu-radio-item-indicator
- Role
- -
Data Attributes
Runtime hooks
State
Group
Groups related Context Menu items.
- Default element
- div
- Discovery hook
- data-sw-menu-group
- Role
- group
Data Attributes
Runtime hooks
Label
Text label associated with Context Menu.
- Default element
- div
- Discovery hook
- data-sw-menu-label
- Role
- -
Data Attributes
Runtime hooks
Separator
Separates groups of Context Menu items.
- Default element
- div
- Discovery hook
- data-sw-menu-separator
- Role
- separator
Data Attributes
Runtime hooks
Shortcut
Displays keyboard shortcut text for a Context Menu item.
- Default element
- span
- Discovery hook
- data-sw-menu-shortcut
- Role
- -
Data Attributes
Runtime hooks
Submenu Root
Owns a nested submenu inside Context Menu.
- Default element
- div
- Discovery hook
- data-sw-menu-submenu-root
- Role
- -
Props
closeDelay number 200
- Description
- Sets how long Context Menu waits before closing.
- Kind
- option
- Targets
- root, submenuRoot
- Full type
- number
Data Attributes
Runtime hooks
State
Metadata
Submenu Trigger
Opens a nested submenu inside Context Menu.
- Default element
- div
- Discovery hook
- data-sw-menu-submenu-trigger
- Role
- menuitem
Props
disabled boolean false
- Description
- Disables the Submenu Trigger part.
- Kind
- option
- Targets
- root, trigger, item, linkItem, checkboxItem, radioItem, submenuTrigger
- Full type
- boolean
Data Attributes
Runtime hooks
State
Metadata
Runtime API
- Factory
createContextMenu- Import
@starwind-ui/runtime/context-menu- Root hook
- root
data-sw-context-menu - Option props
- closeDelay, defaultOpen, disabled, modal, onCloseComplete, onOpenChange, open
Option Lifecycles
| Option | Lifecycle |
|---|---|
| closeDelay | constructor-only |
| defaultOpen | constructor-only |
| disabled | constructor-only |
| modal | constructor-only |
| onCloseComplete | constructor-only |
| onOpenChange | constructor-only |
| open | setter-backed |
Runtime Setters
Related Styled Components
Changelog
View version history v1.3.0 9 releases
v1.3.0
- Context Menu submenu keys follow the reading direction. A menu opened from the keyboard appears at the trigger's reading start edge. Menus that move into a portal keep the direction of their trigger.
- A click during the Context Menu close animation now goes to the page below the menu. Before, the closing menu caught the click, so a quick click on a control under it did nothing.
- When you close a Context Menu with focus inside it, focus now goes back to the trigger as the close starts. The closing menu takes no keyboard input until it hides.
- Escape on a submenu trigger now closes only the open submenu. Before, when you opened a submenu with the pointer and pressed Escape, the whole menu closed. Focus stays on the submenu trigger.
- Context Menu now closes when you press Tab right after the click that opened it. Before, focus left the menu, but it stayed open.
- In a radio group with no `value` or `defaultValue`, an explicit `aria-checked` on a radio item now decides its first state. Before, an item with `aria-checked="false"` and `defaultChecked` could take the group value from a later checked item.
- The `data-default-*` attributes of checkbox and radio items now show only the `default*` prop from when the item mounted. They no longer follow the current value.
- In Svelte, the `data-default-*` attributes of Context Menu now come only from its `default*` props, and `false` flags such as `data-close-on-click` are left out, as in the other frameworks.
- In Vue, this component now needs Vue 3.5.21 or newer.
v1.2.0
- In Astro, an attribute that you set on a Context Menu part now wins over the part's own default for the same attribute, such as `role` or `aria-label`.
- In Svelte, a defined `open`, an item's `checked`, or a radio group's `value` that you pass when ContextMenu mounts now stays under your control, as in React and Vue. To change it, use `bind:` or update your state in the change callback. A form reset keeps it. If you pass `undefined` at mount, ContextMenu keeps its own state.
- In Svelte, the `children` snippet on the Context Menu root no longer receives `open`. Use `bind:open`.
- In Vue, the template ref of the Context Menu root no longer has the undocumented methods `open`, `close`, `updatePosition`, `getValue`, and `setValue`. It exposes only `element`. Use `v-model` on the root instead.
- Fixed a Context Menu trigger on a link or span that stayed disabled when a framework wrote `disabled="false"`. On a native form control, any `disabled` attribute still disables it.
v1.1.2
- Vue checkbox and radio menu items keep their previous selection when a change is canceled.
- Fixed an open menu jumping away from where it was opened when the component updates.
- Reduced background work when a React page uses multiple menus, tooltips, or other portals.
- Reduced background work when a Vue page uses multiple menus, tooltips, or other portals.
- Fixed nested overlays appearing behind their parent in Vue and Svelte. Overlays can now render under the document body; if custom CSS or DOM queries require them to stay inside a parent, set a portal container or add `data-floating-root` to that parent.
- Fixed React 18 retaining removed popup elements when the parent component stays mounted.
- Reduced repeated JavaScript when Astro Context Menu is used with other Starwind components.
- Reduced JavaScript used by Svelte Context Menu. Element props, event handlers, and refs keep the same behavior.
v1.1.1
- Group headings are now linked to their groups with `aria-labelledby`, so screen readers announce the name of each group.
v1.1.0
- Added `container` and `disabled` to the Portal part. `container` sets the element that holds the popup, and `disabled` keeps the popup in place. Portals now place nested popups in the same way every time, and they show their placement in data attributes.
- On touch screens, a parent menu now stays open while focus moves into a submenu, so the submenu stays next to its trigger.
v1.0.0
- This Primitive is now stable at version `1.0.0`. Its API and behavior stay the same as in the previous release.
v0.1.2
- The React Primitive files that the CLI copies into your project are now marked with `"use client"`, so they stay client components in React server frameworks.
- In React, you can cancel a change from its change callback or DOM event before it applies. React then shows only the changes that apply.
v0.1.1
- By default, the page behind the menu no longer scrolls while the menu is open. The `modal` option controls this.
v0.1.0
- First release. Context Menu opens at the pointer and supports keyboard navigation, submenus, and checked items. It places itself to fit on the page.