These cookies are essential for the site to function and cannot be toggled off. They assist with security, user authentication, customer support, etc.
These cookies help us understand how visitors interact with our site. They allow us to measure traffic and improve site performance.
These cookies help us measure the effectiveness of our marketing campaigns.
---import { Button } from '@bejamas/ui/components/button';import { Checkbox } from '@bejamas/ui/components/checkbox';import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '@bejamas/ui/components/dialog';import { Label } from '@bejamas/ui/components/label';---
<Dialog> <DialogTrigger asChild> <Button>Manage Cookies</Button> </DialogTrigger>
<DialogContent class="sm:max-w-lg"> <DialogHeader> <DialogTitle>Manage Cookies</DialogTitle> <DialogDescription> Using websites and apps involves storing and retrieving information from your device, including cookies and other identifiers. </DialogDescription> </DialogHeader> <div class="mt-3"> <div class="flex items-center gap-3"> <Checkbox id="cookies-necessary" name="cookies-necessary" disabled checked /> <Label for="cookies-necessary">Strictly Necessary Cookies (always active)</Label> </div> <p class="text-sm text-muted-foreground ml-8 mt-1">These cookies are essential for the site to function and cannot be toggled off. They assist with security, user authentication, customer support, etc.</p> </div> <div class="mt-3"> <div class="flex items-center gap-3"> <Checkbox id="cookies-analytics" name="cookies-analytics" /> <Label for="cookies-analytics">Analytics Cookies</Label> </div> <p class="text-sm text-muted-foreground ml-8 mt-1">These cookies help us understand how visitors interact with our site. They allow us to measure traffic and improve site performance.</p> </div> <div class="mt-3"> <div class="flex items-center gap-3"> <Checkbox id="cookies-marketing-performance" name="cookies-marketing-performance" /> <Label for="cookies-marketing-performance">Marketing Performance Cookies</Label> </div> <p class="text-sm text-muted-foreground ml-8 mt-1">These cookies help us measure the effectiveness of our marketing campaigns.</p> </div> <DialogFooter> <Button data-slot="dialog-close" class="mt-4" variant="outline">Close</Button> <Button data-dialog-close class="mt-4">Save changes</Button> </DialogFooter> </DialogContent></Dialog>Installation
Section titled “Installation”bunx bejamas add dialognpx bejamas add dialogpnpm dlx bejamas add dialogyarn dlx bejamas add dialog---import { Dialog, DialogTitle, DialogDescription, DialogContent, DialogFooter, DialogClose } from '@bejamas/ui/components/dialog';import { Button } from '@bejamas/ui/components/button';---
<Dialog id="myDialog"> <DialogTrigger>Open Dialog</DialogTrigger> <DialogContent> <DialogTitle>Dialog Title</DialogTitle> <DialogDescription>Dialog description.</DialogDescription> Content here <DialogFooter> <DialogClose>Close</DialogClose> </DialogFooter> </DialogContent></Dialog>| Prop | Type | Default |
|---|---|---|
defaultOpen | boolean | false |
class | string | "" |
closeOnClickOutside | boolean | true |
closeOnEscape | boolean | true |
lockScroll | boolean | true |
Examples
Section titled “Examples”Nested Dialogs
Section titled “Nested Dialogs”---import { Button } from '@bejamas/ui/components/button';import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@bejamas/ui/components/dialog';---
<Dialog> <Button data-slot="dialog-trigger">Open Nested Dialog</Button> <DialogContent class="sm:max-w-lg"> <DialogHeader> <DialogTitle>Nested Dialog</DialogTitle> <DialogDescription> Using websites and apps involves storing and retrieving information from your device, including cookies and other identifiers. </DialogDescription> </DialogHeader> <DialogFooter> <Button data-slot="dialog-close" class="mt-4" variant="outline">Close</Button> <Dialog> <Button data-slot="dialog-trigger" class="mt-4">Open Nested Dialog</Button> <DialogContent class="sm:max-w-md border-red-800"> <DialogHeader> <DialogTitle>Nested Dialog</DialogTitle> <DialogDescription> Using websites and apps involves storing and retrieving information from your device, including cookies and other identifiers. </DialogDescription> </DialogHeader> </DialogContent> </Dialog> </DialogFooter> </DialogContent></Dialog>API Reference
Section titled “API Reference”Events
Section titled “Events”The dialog emits custom events that you can listen to:
| Event | Detail | Description |
|---|---|---|
dialog:change | { open: boolean } | Fired when the open state changes |
<Dialog id="my-dialog"> <DialogTrigger>Open Dialog</DialogTrigger> <DialogContent> <DialogTitle>Title</DialogTitle> <DialogDescription>Description</DialogDescription> </DialogContent></Dialog> const dialog = document.getElementById('my-dialog');
dialog.addEventListener('dialog:change', (e) => { console.log('Is open:', e.detail.open); });Programmatic Control
Section titled “Programmatic Control”You can control the dialog programmatically by dispatching a dialog:set event:
const dialog = document.getElementById('my-dialog');
// Open the dialogdialog.dispatchEvent(new CustomEvent('dialog:set', { detail: { open: true }}));
// Close the dialogdialog.dispatchEvent(new CustomEvent('dialog:set', { detail: { open: false }}));Data Attributes
Section titled “Data Attributes”The dialog sets these data attributes that you can use for styling or querying state:
| Attribute | Element | Description |
|---|---|---|
data-state | dialog | Current state (open or closed) |