React
LoadingonOpenChangeLoading React…
Open one. Five follow. Each tile runs Context Menu in its own framework and reports the change in its own syntax.
Context Menu docs: demo, examples and APIonOpenChangeLoading React…
@open-changeLoading Vue…
onOpenChangeLoading Svelte…
(openChange)Loading Angular…
onOpenChangeLoading Solid…
No changes yet. Use any tile.
The attributes on each framework's Popup element, read from the page while it is open. Open a tile to fill its column.
The showcase example for Context Menu, as written in each framework. Lines that only React has are marked.
import { ContextMenu } from '@▢▢▢▢/react/context-menu'
const areaStyle = {
padding: '32px 48px',
border: '1px dashed var(--demo-border)',
borderRadius: 12,
color: 'var(--demo-muted)',
fontSize: 14,
userSelect: 'none',
WebkitUserSelect: 'none',
} as const
export default function ContextMenuExample() {
return (
<ContextMenu.Root>
<ContextMenu.Trigger style={areaStyle}>
Right click here
</ContextMenu.Trigger>
<ContextMenu.Portal>
<ContextMenu.Positioner>
<ContextMenu.Popup className="menu">
<ContextMenu.Item className="menu-item">
Back
</ContextMenu.Item>
<ContextMenu.Item className="menu-item">
Forward
</ContextMenu.Item>
<ContextMenu.Item className="menu-item">
Reload
</ContextMenu.Item>
<ContextMenu.Item className="menu-item">
Save as...
</ContextMenu.Item>
</ContextMenu.Popup>
</ContextMenu.Positioner>
</ContextMenu.Portal>
</ContextMenu.Root>
)
}
<script setup lang="ts">
import { ContextMenu } from '@▢▢▢▢/vue/context-menu'
const areaStyle = {
padding: '32px 48px',
border: '1px dashed var(--demo-border)',
borderRadius: '12px',
color: 'var(--demo-muted)',
fontSize: '14px',
userSelect: 'none',
WebkitUserSelect: 'none',
} as const
</script>
<template>
<ContextMenu.Root>
<ContextMenu.Trigger :style="areaStyle"
>Right click here</ContextMenu.Trigger
>
<ContextMenu.Portal>
<ContextMenu.Positioner>
<ContextMenu.Popup class="menu">
<ContextMenu.Item class="menu-item">Back</ContextMenu.Item>
<ContextMenu.Item class="menu-item">Forward</ContextMenu.Item>
<ContextMenu.Item class="menu-item">Reload</ContextMenu.Item>
<ContextMenu.Item class="menu-item">Save as...</ContextMenu.Item>
</ContextMenu.Popup>
</ContextMenu.Positioner>
</ContextMenu.Portal>
</ContextMenu.Root>
</template>
Context Menu in each framework, side by side. Lower is better for size, time and memory. No outside baseline: the frameworks are compared with each other only.
The ContextMenu.Root props as each framework writes them. A name that differs from React is marked.
onCheckedChange(checked, details), onOpenChange(open, details), onValueChange(value, details).:default-checked, :side-offset). Upstream's callbacks are Vue events with the same arguments: checkedChange(checked, details), openChange(open, details), valueChange(value, details).onCheckedChange(checked, details), onOpenChange(open, details), onValueChange(value, details), with details.cancel(), reason and event. Native event props use Svelte's names (onclick, onkeydown).checked, disabled, nativeButton); boolean inputs also work as bare attributes. Each callback with details is an output named without on: checkedChange, openChange, valueChange.onCheckedChange(checked, details), with details.cancel() and details.event. Native handlers are camelCase (onClick, onKeyDown), as Solid 2 requires.defaultOpenpropdefaultOpendefault-opendefaultOpen[defaultOpen]defaultOpenopenpropopenopenopen[open]openonOpenChangeeventonOpenChange@open-changeonOpenChange(openChange)onOpenChangehighlightItemOnHoverprophighlightItemOnHoverhighlight-item-on-hoverhighlightItemOnHover[highlightItemOnHover]highlightItemOnHoveractionsRefpropactionsRefactions-refactionsRef[actionsRef]actionsRefloopFocusproploopFocusloop-focusloopFocus[loopFocus]loopFocusonItemHighlightedeventonItemHighlightedon-item-highlightedonItemHighlighted(itemHighlighted)onItemHighlightedonOpenChangeCompleteeventonOpenChangeComplete@open-change-completeonOpenChangeComplete(openChangeComplete)onOpenChangeCompletedisabledpropdisableddisableddisabled[disabled]disabledorientationproporientationorientationorientation[orientation]orientationchildrenpropchildren#defaultchildrenng-contentchildren