Base UI (Angular) dialogs are modals you open with DialogService.open(), not a router outlet. The CLI copies the overlay, focus trap, and header/body/footer pieces into your app. On the server, open() is a no-op so prerender stays SSR-safe. Close with a typed result via DialogContext.
Install with npx base-ui-cli add dialog.
Basic Dialog example below
Dialog containing form elements and date pickers to gather information.
A simple confirmation dialog for destructive or important actions.
Dialogs with long content automatically enable scrolling in the body while keeps header and footer fixed. Use the height property to set a fixed height or a large enough value for full-screen feel.
While a mutation is in flight, swap the confirm action for base-progress-button and disable dismiss if rollback is unsafe.
Site-wide VPAT-style notes live on the accessibility report.
Run the following command to add this component to your project:
npx base-ui-cli add dialog
For AI agents
Copy a prompt with the registry name, CLI install, and import — or add the Base UI MCP server.
npx -y base-ui-mcp
Base UI provides standalone components. Import the exact elements you want to use into your component.
// Install: npx base-ui-cli add dialog
// Paths are relative to aliases.components (default: src/app/components)
import { DialogBodyComponent } from './dialog/dialog-body/dialog-body.component';
import { DialogCloseDirective } from './dialog/dialog-close.directive';
import { DialogContainer } from './dialog/dialog-container';
import { DialogService } from './dialog/dialog.service';
import { DialogComponent } from './dialog/dialog/dialog.component';
@Component({
selector: 'app-your-component',
imports: [
DialogBodyComponent,
DialogCloseDirective,
DialogComponent
],
template: `...`
})
export class YourComponent {
private dialog = inject(DialogService);
} API for dialog — generated from JSDoc in the library source.
| API | Member | Type | Default | Description |
|---|---|---|---|---|
DialogService | open() | (type: Type<unknown>, data?: TData, className?: string, options: { hideOnBackdropClick?: boolean; containerType?: Type<DialogContainer> } = {}) => Observable<TResult | undefined> | — | Opens a component dynamically inside a dialog container. On the server this returns `of(undefined)` and does not touch the DOM. |
DialogContainer | context | DialogContext<unknown, unknown> | — | The dialog context injected into the hosted component. |
DialogContainer | container | Signal<ViewContainerRef> | — | The ViewContainerRef where the dialog content is dynamically rendered. |
DialogContainer | className | string | — | Optional CSS class string applied to the container wrapper. |
base-dialog | width | number | string | — | Explicit width: pixels as a number or any CSS width string (e.g. `'640'`, `'48rem'`). |
base-dialog | height | number | — | Explicit height in pixels. Applied dynamically to the `base-dialog-body` for scrolling. |
base-dialog-body | height | number | — | — |
[base-dialog-close] | ariaLabel | string | — | Optional aria-label for accessibility. |
[base-dialog-close] | type | unknown | 'button' | The native button type. Defaults to 'button'. |
Content