Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

CompareMenus

Context Menu in five frameworks

The same example, live in each framework. One core underneath, so they should behave the same.

Back to the Context Menu docs

Live

React

Loading19.3.1

Loading React…

No event yet

Vue

Loading3.5.44

Loading Vue…

No event yet

Svelte

Loading5.57.3

Loading Svelte…

No event yet

Solid

Loading2.0.0-rc.21

Loading Solid…

No event yet

Angular

Loading22.2.4

Loading Angular…

No event yet

The attributes each framework puts on the open popup, read from the page.

AttributeReactVueSvelteSolidAngular
roleClosedClosedClosedClosedClosed
aria-modalClosedClosedClosedClosedClosed
aria-labelledbyClosedClosedClosedClosedClosed
data-openClosedClosedClosedClosedClosed

Nothing open. Open a tile to fill its column.

The same example, in each framework

Each tile above runs this file.

ContextMenu.tsx
import { ContextMenu } from '@hamur/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>
  )
}

Measured, per framework

The frameworks against each other only, on the same machine and the same example.

FrameworkTestsSizeOpenCloseMemory
React7971.6 KiB5.00 ms14.3 ms1.13 MiB
Vue8171.8 KiB5.10 ms14.1 ms2.53 MiB
Svelte8066.8 KiB7.00 ms12.1 ms2.45 MiB
Solid9065.2 KiB4.70 ms14.4 ms1.66 MiB
Angular7676.6 KiB5.80 ms12.4 ms0.89 MiB

Size is the gzip of the component's entry with core and dom. Open, Close and Memory are medians in Chromium 156 on Apple M3 Max, 35 runs per framework; Memory is what one open and close leaves on the heap. Tests are Context Menu's passing tests in each framework's suites. [N] is a value not measured yet.

Same props, five spellings

The ContextMenu.Root names in each framework's own syntax.

PropReactVueSvelteSolidAngular
defaultOpendefaultOpendefault-opendefaultOpendefaultOpen[defaultOpen]
openopenopenopenopen[open]
onOpenChangeeventonOpenChange@open-changeonOpenChangeonOpenChange(openChange)
highlightItemOnHoverhighlightItemOnHoverhighlight-item-on-hoverhighlightItemOnHoverhighlightItemOnHover[highlightItemOnHover]
actionsRefactionsRefactions-refactionsRefactionsRef[actionsRef]
loopFocusloopFocusloop-focusloopFocusloopFocus[loopFocus]
onItemHighlightedeventonItemHighlightedon-item-highlightedonItemHighlightedonItemHighlighted(itemHighlighted)
onOpenChangeCompleteeventonOpenChangeComplete@open-change-completeonOpenChangeCompleteonOpenChangeComplete(openChangeComplete)
disableddisableddisableddisableddisabled[disabled]
orientationorientationorientationorientationorientation[orientation]
childrenchildren#defaultchildrenchildrenng-content