Skip to content

Dialog

A window overlaid on either the primary window or another dialog window.

Open Dialog

Installation

bash
npx @galaxy-stack/nebula-cli@latest add dialog
bash
pnpm dlx @galaxy-stack/nebula-cli@latest add dialog
bash
yarn dlx @galaxy-stack/nebula-cli@latest add dialog
bash
bunx @galaxy-stack/nebula-cli@latest add dialog
bash
# If you have installed galaxy-design globally
galaxy-design add dialog

Dependencies

This component automatically installs the following dependencies:

  • React: @radix-ui/react-dialog
  • Vue: radix-vue
  • Angular: @radix-ng/primitives

No manual installation needed!

Usage

React

tsx
import {
  Dialog,
  DialogTrigger,
  DialogContent,
  DialogHeader,
  DialogTitle,
  DialogDescription,
  DialogClose,
} from "@/components/ui/dialog"

export default function App() {
  return (
    <Dialog>
      <DialogTrigger asChild>
        <Button>Open Dialog</Button>
      </DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Dialog Title</DialogTitle>
          <DialogDescription>
            This is a description of the dialog.
          </DialogDescription>
        </DialogHeader>
        <DialogClose asChild>
          <Button variant="outline">Close</Button>
        </DialogClose>
      </DialogContent>
    </Dialog>
  )
}

Vue

vue
<script setup lang="ts">
import {
  Dialog,
  DialogTrigger,
  DialogContent,
  DialogHeader,
  DialogTitle,
  DialogDescription,
  DialogClose,
} from '@/components/ui/dialog'
</script>

<template>
  <Dialog>
    <DialogTrigger asChild>
      <Button>Open Dialog</Button>
    </DialogTrigger>
    <DialogContent>
      <DialogHeader>
        <DialogTitle>Dialog Title</DialogTitle>
        <DialogDescription>
          This is a description of the dialog.
        </DialogDescription>
      </DialogHeader>
      <DialogClose asChild>
        <Button variant="outline">Close</Button>
      </DialogClose>
    </DialogContent>
  </Dialog>
</template>

Angular

typescript
import { Component } from '@angular/core';
import { DialogComponent } from '@/components/ui/dialog';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [DialogComponent],
  template: `
    <ui-dialog>
      <button trigger>Open Dialog</button>
      <div content>
        <ui-dialog-header>
          <ui-dialog-title>Dialog Title</ui-dialog-title>
          <ui-dialog-description>
            This is a description of the dialog.
          </ui-dialog-description>
        </ui-dialog-header>
        <button close>Close</button>
      </div>
    </ui-dialog>
  `
})
export class AppComponent {}

React Native

tsx
import {
  Dialog,
  DialogTrigger,
  DialogContent,
  DialogHeader,
  DialogTitle,
  DialogDescription,
  DialogClose,
} from '@/components/ui/dialog'
import { Button, ButtonText } from '@/components/ui/button'

export default function App() {
  return (
    <Dialog>
      <DialogTrigger asChild>
        <Button><ButtonText>Open Dialog</ButtonText></Button>
      </DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Dialog Title</DialogTitle>
          <DialogDescription>
            This is a description of the dialog.
          </DialogDescription>
        </DialogHeader>
        <DialogClose asChild>
          <Button variant="outline">
            <ButtonText>Close</ButtonText>
          </Button>
        </DialogClose>
      </DialogContent>
    </Dialog>
  )
}

Flutter

dart
import 'package:flutter/material.dart';
import 'package:galaxy_design/galaxy_dialog.dart';

class DialogExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GalaxyButton(
      onPressed: () {
        showDialog(
          context: context,
          builder: (context) => GalaxyDialog(
            title: 'Dialog Title',
            description: 'This is a description of the dialog.',
            actions: [
              GalaxyButton(
                onPressed: () => Navigator.pop(context),
                child: const Text('Close'),
              ),
            ],
          ),
        );
      },
      child: const Text('Open Dialog'),
    );
  }
}

API Reference

Props

PropTypeDefaultDescriptionFrameworks
openbooleanundefinedControlled open stateAll
defaultOpenbooleanfalseInitial open stateAll
onOpenChange(open: boolean) => void-Called when open state changesAll
modalbooleantrueWhether interaction outside is disabledAll
classNamestring''CSS class namesReact, React Native
classstring''CSS class namesVue, Angular, Flutter

Subcomponents

DialogTrigger

PropTypeDefaultDescriptionFrameworks
asChildbooleanfalseRender as child elementReact, Vue, Angular
classNamestring''CSS class namesReact, React Native
classstring''CSS class namesVue, Angular, Flutter

DialogContent

PropTypeDefaultDescriptionFrameworks
asChildbooleanfalseRender as child elementReact, Vue, Angular
classNamestring''CSS class namesReact, React Native
classstring''CSS class namesVue, Angular, Flutter

DialogHeader

PropTypeDefaultDescriptionFrameworks
classNamestring''CSS class namesReact, React Native
classstring''CSS class namesVue, Angular, Flutter

DialogTitle

PropTypeDefaultDescriptionFrameworks
asChildbooleanfalseRender as child elementReact, Vue, Angular
classNamestring''CSS class namesReact, React Native
classstring''CSS class namesVue, Angular, Flutter

DialogDescription

PropTypeDefaultDescriptionFrameworks
asChildbooleanfalseRender as child elementReact, Vue, Angular
classNamestring''CSS class namesReact, React Native
classstring''CSS class namesVue, Angular, Flutter

DialogClose

PropTypeDefaultDescriptionFrameworks
asChildbooleanfalseRender as child elementReact, Vue, Angular
classNamestring''CSS class namesReact, React Native
classstring''CSS class namesVue, Angular, Flutter

Subcomponents

DialogTrigger

Button to open the dialog

DialogContent

The dialog content container

DialogHeader

Header section of dialog

DialogTitle

Title of the dialog

DialogDescription

Description text

DialogFooter

Footer section for actions

Accessibility

  • Keyboard Navigation: Escape to close, Tab to navigate within
  • Screen Reader: Uses dialog role with proper labeling
  • Focus Management: Focus trapped within dialog when open
  • WCAG Compliance: WCAG 2.1 Level AA compliant

Author

Bùi Trọng Hiếu (kevinbui)

License

MIT © 2025 Bùi Trọng Hiếu (kevinbui)

Released under the MIT License.