Skip to main content
LibreChat is joining ClickHouse to power the open-source Agentic Data Stack 🎉 Learn more
LibreChat

Dialog

Modal dialogs and confirmations.

LibreChat's modal dialog is built from OGDialog and its parts. For a standard dialog with a title, a body and a confirm action, OGDialogTemplate assembles them and adds a localized Cancel button.

import { Button, OGDialog, OGDialogTemplate, OGDialogTrigger } from '@librechat/client'

export default function DialogConfirm() {
  return (
    <OGDialog>
      <OGDialogTrigger asChild>
        <Button variant="destructive">Delete conversation</Button>
      </OGDialogTrigger>
      <OGDialogTemplate
        title="Delete conversation?"
        className="w-11/12 max-w-md"
        main={<p className="text-text-secondary text-sm">This removes it for good.</p>}
        selection={{
          selectHandler: () => undefined,
          selectClasses:
            'bg-surface-destructive hover:bg-surface-destructive-hover text-text-on-status',
          selectText: 'Delete',
        }}
        showCancelButton
      />
    </OGDialog>
  )
}

The next release of @librechat/client also exports these parts under plain names (Dialog, DialogContent, DialogTemplate and the rest). They are the same components, so either name works once that release is out.

Parts

PartRole
OGDialogThe root; controls whether the dialog is open.
OGDialogTriggerThe element that opens it. Use asChild with a Button.
OGDialogContentThe dialog surface, with an optional close button.
OGDialogHeader, OGDialogTitle, OGDialogDescriptionThe heading area. Every dialog needs a title.
OGDialogFooter, OGDialogCloseThe action row and a control that closes the dialog.
OGDialogTemplateA complete dialog: title, main, selection and an optional Cancel button.

Width and dismissal

Constrain a dialog to w-11/12 plus a max-w-* cap so it holds up from desktop to phone, and give it exactly one clear way out: the close button or a Cancel button.

Accessibility

Opening the dialog moves focus into it and keeps focus inside until it closes; closing returns focus to the trigger. For a destructive confirmation, AlertDialog gives screen readers the stronger alertdialog role.

KeyAction
Tab and Shift+TabMove between the dialog's controls
EscapeCloses the dialog and returns focus to the trigger

How is this guide?