Dialog

A task on its own, over the page. The app's dialog: on the most raised surface with a hairline edge, divided into header, sections and footer.

Example

<Dialog bind:open>
	<DialogTrigger>
		{#snippet child({ props })}<Button {...props} variant="primary">Invite</Button>{/snippet}
	</DialogTrigger>
	<DialogContent>
		<DialogHeader>
			<DialogTitle>Invite a member</DialogTitle>
			<DialogDescription>They get an email with a link to join.</DialogDescription>
		</DialogHeader>
		<DialogSection class="grid gap-6">
			<Field label="Email"><Input type="email" /></Field>
			<Field label="Role"><Select options={roles} /></Field>
		</DialogSection>
		<DialogFooter>
			<DialogClose>{#snippet child({ props })}<Button {...props}>Cancel</Button>{/snippet}</DialogClose>
			<Button variant="primary" loadingText="Sending..." {...invite.button} onclick={invite.run}>
				Send invite
			</Button>
		</DialogFooter>
	</DialogContent>
</Dialog>

Anatomy

Header
Title, and a description when it adds something. A line under it.
Sections
The body, 24px in from the edges. More than one are split by dashed lines.
Footer
Actions on the right, main one last. A line over it. Stacked on a phone, main one on top.
Close
The X top right, Escape, or a click outside. All of them mean cancel.

Rules

  • For a short task that needs the page behind it. Anything longer gets its own page.
  • The title says the task, as in the button that opened it: "Invite a member".
  • The main button names the action ("Send invite"), never OK or Submit.
  • Asking before something can't be undone: the Confirm dialog, not a hand-built one.