Import
Copy code
import { Dialog } from '@k8ordo/ui';
import { Modal } from '@k8ordo/ui';Usage
Dialog Title
Dialog content here
Copy code
<Dialog.Root>
<Dialog.Header onClose={handleClose} title="Dialog Title" />
<Dialog.Content>Dialog content here</Dialog.Content>
</Dialog.Root>Basic usage
Copy code
const [isOpen, setIsOpen] = useState(false);
<Button onClick={() => setIsOpen(true)}>
Open Dialog
</Button>
<Modal
isOpen={isOpen}
onClose={() => setIsOpen(false)}
side="center"
>
<Dialog.Root>
<Dialog.Header
onClose={() => setIsOpen(false)}
title="Confirmation"
/>
<Dialog.Content>
<p>Are you sure you want to proceed?</p>
</Dialog.Content>
</Dialog.Root>
</Modal>Alert dialog
Copy code
const [isOpen, setIsOpen] = useState(false);
<Button onClick={() => setIsOpen(true)}>Delete Item</Button>
<Modal
isOpen={isOpen}
onClose={() => setIsOpen(false)}
side="center"
>
<Dialog.Root role="alertdialog">
<Dialog.Header
onClose={() => setIsOpen(false)}
title="Delete Confirmation"
/>
<Dialog.Content>
<div className={styles.body}>
<p>
Are you sure you want to delete this item?
This action cannot be undone.
</p>
<div className={styles.actions}>
<Button
color="base"
onClick={() => setIsOpen(false)}
variant="outline"
>
Cancel
</Button>
<Button onClick={() => setIsOpen(false)}>
Delete
</Button>
</div>
</div>
</Dialog.Content>
</Dialog.Root>
</Modal>Props
Dialog.Root
children?- Type:
ReactNode - Default: -
id?- Type:
string - Default: -
ref?- Type:
Ref<HTMLElement> - Default: -
role?- Type:
'dialog'|'alertdialog' - Default: -
tabIndex?- Type:
number - Default: -
| Prop | Type | Default |
|---|---|---|
children? | ReactNode | - |
id? | string | - |
ref? | Ref<HTMLElement> | - |
role? | 'dialog'|'alertdialog' | - |
tabIndex? | number | - |
Dialog.Header
onClose- Type:
() => void - Default: -
title- Type:
ReactNode - Default: -
| Prop | Type | Default |
|---|---|---|
onClose | () => void | - |
title | ReactNode | - |
Dialog.Content
children?- Type:
ReactNode - Default: -
| Prop | Type | Default |
|---|---|---|
children? | ReactNode | - |