All components

Dialog

Put a focused task in a modal.

Examples

Put a focused task in a modal

Request details

Assigned to the operations team.

React code
import {
  DialogTrigger,
  Dialog,
  DialogTitle,
  DialogDescription,
  DialogClose,
} from "@accelerate/react/components";

export function Example() {
  return (
    <>
      <DialogTrigger aria-controls="details-dialog">View request</DialogTrigger>
      <Dialog id="details-dialog" aria-labelledby="details-title">
        <DialogTitle id="details-title">Request details</DialogTitle>
        <DialogDescription>Assigned to the operations team.</DialogDescription>
        <DialogClose>Close</DialogClose>
      </Dialog>
    </>
  );
}
Angular code
import { Component } from "@angular/core";
import {
  AccDialogTrigger,
  AccDialog,
  AccDialogTitle,
  AccDialogDescription,
  AccDialogClose,
} from "@accelerate/angular/components";

@Component({
  selector: "app-example",
  imports: [
    AccDialogTrigger,
    AccDialog,
    AccDialogTitle,
    AccDialogDescription,
    AccDialogClose,
  ],
  template: `
    <button accDialogTrigger aria-controls="details-dialog">View request</button>
    <dialog accDialog id="details-dialog" aria-labelledby="details-title">
      <h2 accDialogTitle id="details-title">Request details</h2>
      <p accDialogDescription>Assigned to the operations team.</p>
      <button accDialogClose>Close</button>
    </dialog>
  `,
})
export class Example {}

Installation

Source preview. The expanded component catalog is ahead of the public npm releases. To run these examples in your own application, use packages built from the SDK source used for the previews or a release that includes the APIs below.

React
@accelerate/ui@0.4.0 and @accelerate/react@0.4.0
Angular
@accelerate/ui@0.4.0 and @accelerate/angular@0.2.0

Load @accelerate/ui/theme.css and put acc-theme on the app or the region using Accelerator components. See the framework setup guide for the theme and adapter conventions.

Usage

Target its ID with DialogTrigger aria-controls. Label the dialog via aria-labelledby and optionally aria-describedby. Use DialogClose or a native method="dialog" form.

Import the React component Dialog from @accelerate/react/components. For Angular, add AccDialog to the standalone component’s imports and use <dialog accDialog>.

Examples use these React parts: DialogTrigger, Dialog, DialogTitle, DialogDescription, DialogClose. The Angular examples show the corresponding directives and template hosts.

API reference

DialogTrigger aria-controls
Points to the dialog ID.
aria-labelledby
Gives the modal an accessible name.
Escape
Uses the browser’s native modal dismissal.