Skip to main content

Dialog

note

This component is intended for staff-facing use only.

Use a dialog to:

  • have a user confirm a potentially dangerous or destructive action
  • allow a user to "peek" at the details of something without losing the context of the page underneath

Dialogs should only allow a user to take a single action. If many actions are possible, use a whole page instead.

React​

Our dialog component is only compatible with React. It uses Radix UI Dialog for accessible modal behaviour.

Import from the main package entry or the Dialog subpath:

import React, { useState } from "react"
import { Dialog } from "lbh-frontend"
// or
import Dialog from "lbh-frontend/dialog"

Use the subpath when you only need Dialog and want to avoid importing the full package bundle.

Informational (dismiss only)​

const [open, setOpen] = useState(false)

<Dialog title="More information" isOpen={open} onDismiss={() => setOpen(false)}>
<p className="lbh-body">Use the close button to dismiss this dialog.</p>
</Dialog>

Confirm and cancel​

Optional actions render in .lbh-dialog__actions using existing design system button and link styles.

<Dialog
title="Are you sure?"
isOpen={open}
onDismiss={() => setOpen(false)}
onConfirm={() => setOpen(false)}
confirmText="Yes, delete"
onCancel={() => setOpen(false)}
>
<p className="lbh-body">The record will be permanently deleted.</p>
</Dialog>
<Dialog
title="Contact details"
isOpen={open}
onDismiss={() => setOpen(false)}
onCancel={() => setOpen(false)}
cancelText="Close"
>
<p className="lbh-body">123 Example Street, London</p>
</Dialog>

Props​

PropTypeRequiredDefaultDescription
isOpenbooleanYes—Controls whether the dialog is visible
onDismiss() => voidYes—Called when the user closes via the X button or overlay
titlestringYes—Dialog heading
childrenReactNodeYes—Main dialog content
onConfirm() => voidNo—Primary action handler
confirmTextstringNo"Yes"Primary action label
confirmButtonTestIdstringNo—data-testid for the confirm button
onCancel() => voidNo—Secondary action handler
cancelTextstringNo"No, cancel"Secondary action label

If both onConfirm and onCancel are omitted, no action footer is rendered.