Compare
Component
Compare · 11 components with a popup

Alert Dialog, five ways

Open one. Five follow. Each tile runs Alert Dialog in its own framework and reports the change in its own syntax.

Alert Dialog docs: demo, examples and API
Frameworks
5
Parts
9
Open now
0 of 5
Events
0

Live

Sync on · one tile drives all five

React

LoadingonOpenChange

Loading React…

Vue

Loading@open-change

Loading Vue…

Svelte

LoadingonOpenChange

Loading Svelte…

Angular

Loading(openChange)

Loading Angular…

Solid

LoadingonOpenChange

Loading Solid…

EventsNo changes yet

No changes yet. Use any tile.

The same example, in each framework

The showcase example for Alert Dialog, as written in each framework. Lines that only React has are marked.

React · AlertDialog.tsx21 lines only in React
import { AlertDialog } from '@▢▢▢▢/react/alert-dialog'

export default function AlertDialogExample() {
  return (
    <AlertDialog.Root>
      <AlertDialog.Trigger className="button danger">
        Delete project
      </AlertDialog.Trigger>
      <AlertDialog.Portal>
        <AlertDialog.Backdrop className="backdrop" />
        <AlertDialog.Popup className="dialog">
          <AlertDialog.Title className="dialog-title">
            Delete this project?
          </AlertDialog.Title>
          <AlertDialog.Description className="muted">
            All of its files and settings will be removed for everyone.
          </AlertDialog.Description>
          <div className="actions">
            <AlertDialog.Close className="button">
              Cancel
            </AlertDialog.Close>
            <AlertDialog.Close className="button danger">
              Delete
            </AlertDialog.Close>
          </div>
        </AlertDialog.Popup>
      </AlertDialog.Portal>
    </AlertDialog.Root>
  )
}
AlertDialog.vue
<script setup lang="ts">
import { AlertDialog } from '@▢▢▢▢/vue/alert-dialog'
</script>

<template>
  <AlertDialog.Root>
    <AlertDialog.Trigger class="button danger"
      >Delete project</AlertDialog.Trigger
    >
    <AlertDialog.Portal>
      <AlertDialog.Backdrop class="backdrop" />
      <AlertDialog.Popup class="dialog">
        <AlertDialog.Title class="dialog-title"
          >Delete this project?</AlertDialog.Title
        >
        <AlertDialog.Description class="muted">
          All of its files and settings will be removed for everyone.
        </AlertDialog.Description>
        <div class="actions">
          <AlertDialog.Close class="button">Cancel</AlertDialog.Close>
          <AlertDialog.Close class="button danger">Delete</AlertDialog.Close>
        </div>
      </AlertDialog.Popup>
    </AlertDialog.Portal>
  </AlertDialog.Root>
</template>

Measured, per framework

Alert Dialog 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.

MetricReactVueSvelteAngularSolid
SizeKiB gzip, with core and dom
Openms, median
Closems, median
MemoryMiB after one open and close
Testspassing
Measured
Nov 5 on Apple M3 Max, Chromium 156, 35 runs per framework over 5 page loads. The range under each time is the spread of the per-load medians.
Tests
Alert Dialog's tests in each framework's suites, jsdom and Chromium together, from the latest run. React runs the React tests on the port; the other four also run the shared behaviour tests.
Sources
reports/size-baseline.json (size), reports/perf.json (shared code, time, memory) and reports/tests-by-component.json (tests).

Same props, five spellings

The AlertDialog.Root props as each framework writes them. A name that differs from React is marked.

React
Props and callbacks have upstream's names and signatures: onCheckedChange(checked, details), onOpenChange(open, details), onValueChange(value, details).
Vue
Props keep upstream's names and can be written in kebab case in a template (:default-checked, :side-offset). Upstream's callbacks are Vue events with the same arguments: checkedChange(checked, details), openChange(open, details), valueChange(value, details).
Svelte
Callbacks are props with upstream's names and arguments: onCheckedChange(checked, details), onOpenChange(open, details), onValueChange(value, details), with details.cancel(), reason and event. Native event props use Svelte's names (onclick, onkeydown).
Angular
Inputs are signal inputs with upstream's names (checked, disabled, nativeButton); boolean inputs also work as bare attributes. Each callback with details is an output named without on: checkedChange, openChange, valueChange.
Solid
Callbacks keep upstream's names and arguments: onCheckedChange(checked, details), with details.cancel() and details.event. Native handlers are camelCase (onClick, onKeyDown), as Solid 2 requires.
Prop · 9ReactVueSvelteAngularSolid
defaultOpenpropdefaultOpendefault-opendefaultOpen[defaultOpen]defaultOpen
openpropopenopenopen[open]open
onOpenChangeeventonOpenChange@open-changeonOpenChange(openChange)onOpenChange
actionsRefpropactionsRefactions-refactionsRef[actionsRef]actionsRef
defaultTriggerIdpropdefaultTriggerIddefault-trigger-iddefaultTriggerId[defaultTriggerId]defaultTriggerId
handleprophandlehandlehandle[handle]handle
onOpenChangeCompleteeventonOpenChangeComplete@open-change-completeonOpenChangeComplete(openChangeComplete)onOpenChangeComplete
triggerIdproptriggerIdtrigger-idtriggerId[triggerId]triggerId
childrenpropchildren#defaultchildrenng-contentchildren