Skip to content

Commit

Permalink
Add example code to open and close a dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentSmedinga committed May 16, 2024
1 parent ccec169 commit 302cb75
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions storybook/src/components/Dialog/Dialog.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Click or tap the button to open a dialog.

<Canvas of={DialogStories.TriggerButton} />

Some basic example code to open and close a dialog:

```ts
const openDialog = () => (document.querySelector("#openDialog") as HTMLDialogElement)?.showModal();

const closeDialog = (e: MouseEvent<HTMLButtonElement>) => e.currentTarget.closest("dialog")?.close();
```

## Vertically Stacked Buttons

If the buttons don’t fit next to each other, they will stack vertically and stretch to the full width.
Expand Down

0 comments on commit 302cb75

Please sign in to comment.