Harbour UI

Modal

Accessible dialog overlay. Traps focus within the dialog, closes on Escape key press, locks background scroll, and restores it on unmount.

Preview

Usage

jsx
import { Modal } from '@/components/ui'
import { useState } from 'react'

function Example() {
  const [open, setOpen] = useState(false)

  return (
    <>
      <Button class="text-sky-300">onClick={() => setOpen(true)}>Open</Button>
      <Modal
        class="text-sky-300">open={open}
        class="text-sky-300">onClose={() => setOpen(false)}
        class="text-sky-300">title="Confirm"
        class="text-sky-300">size="sm"
      >
        <p>Are you sure?</p>
      </Modal>
    </>
  )
}

Props

PropTypeDefaultDescription
open*booleanControls visibility.
onClose*() => voidCalled when the user dismisses the modal.
titlestringDialog title (used for aria-labelledby).
size'sm' | 'md' | 'lg''md'Max width of the dialog.