Components Menus and overlays

Dialog

A modal (or modeless) dialog with a title, content, and actions; it traps focus and closes on Escape.

import { Dialog } from '@kition/tessera-ui'

When to use

  • A short task that needs values before it runs.

When not to

  • Long forms: use a panel or a page.

Examples

Image size
dialog.tsx
import { useState } from 'react'
import { Button, Dialog, NumberField } from '@kition/tessera-ui'

export default function Demo() {
  const [open, setOpen] = useState(false)
  const [width, setWidth] = useState(1920)
  return (
    <>
      <Button onClick={() => setOpen(true)}>Image size…</Button>
      {open ? (
        <Dialog
          title="Image size"
          onClose={() => setOpen(false)}
          actions={
            <>
              <Button onClick={() => setOpen(false)}>Cancel</Button>
              <Button variant="primary" onClick={() => setOpen(false)}>OK</Button>
            </>
          }
        >
          <NumberField label="Width" value={width} min={1} max={10000} unit="px" onChange={(value) => setWidth(value)} />
        </Dialog>
      ) : null}
    </>
  )
}

Props

Dialog

PropTypeDefaultDescription
titlerequiredstring—
childrenrequiredReactNode—
actionsrequiredReactNode—
onCloserequired() => void—
onEscape(event: KeyboardEvent) => void—Called for Escape in place of onClose (a dialog that lets a field keep its own Escape).
modalbooleantrueBlocks the page behind a backdrop (the default), where a press outside closes it. With false the page stays usable: no backdrop, and the editor keeps its keys.
uiIdstring—
testIdstring—
position{ x: number; y: number } | null—Where the dialog's top left sits in the window (with onMove); null or absent: where the layout puts it.
onMove(position: { x: number; y: number }) => void—Makes the dialog movable by its title: a drag moves it, and its place is reported once, on release (keep it, and give it back as position). Absent, the title does not move it.

Used in

8 of Kition's 16 kits use this component.

  • Board
  • Cube
  • Design
  • Film
  • Note
  • Photo
  • Slide
  • Vector