Skip to content

AlertDialog

Tells the person something they must see before going on, with one button to acknowledge it. It informs; to ask for a decision, use ConfirmDialog.

import { AlertDialog } from '@sypnia/ui/react'

On this page
  1. A limit reached
  2. When to use it
  3. For everyone
  4. Props

A limit reached

Open it: the button has the focus; clicking outside does nothing.

Code
import { useState } from 'react';
import { AlertDialog, Button } from '@sypnia/ui/react';

// It informs and waits for the person to acknowledge it. Clicking outside does not close it.
export default function SessionEnded() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Reach the limit</Button>
      <AlertDialog open={open} onClose={() => setOpen(false)} title="This project reached its storage limit">
        New rows are not saved until there is room. Delete old files or move to a larger plan; the rows you already have are safe.
      </AlertDialog>
    </>
  );
}

When to use it

Use it when

  • Something happened that changes what the person can do now: a limit reached, a session ended.
  • Say what happened and what it means in plain words; the button can say what comes next.

Do not use it when

  • Asking a question with two answers: use ConfirmDialog.
  • Results of what the person just did: use a toast.
  • Problems that belong to one part of the page: use an Alert there.

For everyone

  • It is an alertdialog: a screen reader reads its title and text when it opens.
  • The only button has the focus. A press outside does nothing, by design: the person acknowledges it with the button or Escape.

Props

AlertDialogTypeDefault
onCloserequired () => void
titlerequired ReactNode
action

The button's words. Defaults to «Got it».

string
children

What happened and what it means for the person.

ReactNode
open boolean true
  1. A limit reached
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms