Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Overlays & Actions

Dialog

Modal dialog with backdrop, centered panel, default close control, Escape + focus return, `presentation="slot"` for custom layouts (Alert Dialog, full-screen previews). Reveal the right amount of context without losing the user's place in the interface. Keep the trigger, content and dismissal behavior working as one interaction. Import it from @/components/kamod-ui/dialog.

Source · Design reference · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Install @kamod-ch/ui, then compose Dialog, DialogTrigger, and DialogContent as in the snippet below. The default modal is centered; for immersive full-viewport layouts use presentation="slot" and apply overlay + panel classes on DialogContent yourself (see Usage). Motion is optional — see With Motion for @kamod-ch/ui-motion.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Usage

Default DialogContent is presentation="modal" (backdrop + centered panel). If your code used to put `fixed inset-0`, `flex items-center justify-center`, and `bg-black/50` on DialogContent itself, you must set `presentation="slot"` — otherwise you get two backdrops and a nested centered shell. Same pattern as AlertDialogContent and the docs “View Markdown” dialog. Width-only classes like sm:max-w-md on modal are fine without slot. lockBodyScroll defaults to true on Dialog.

Import SetupTypeScript
import { Dialog } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Component Examples & Variants

Explore Dialog in Different Contexts, from the starting pattern to the compositions below. Begin with Custom Layout: Presentation="slot", then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Custom Layout: Presentation="slot"

Own the Visual Shell without Duplicating It. Use presentation="slot" on DialogContent when the composition provides its own fixed overlay, backdrop and centered panel. This avoids stacking your layout inside the default modal's already-provided overlay and surface.

Keep the dialog's title, description, focus containment and dismissal behavior intact while supplying your own surface; test scrolling and narrow screens as carefully as the centered desktop state.

src/components/DialogExample.tsx22 lines
import { Button, Dialog, DialogClose, DialogContent, DialogTrigger } from "@kamod-ch/ui";

export const Example = () => (
  <Dialog>
    <DialogTrigger asChild>
      <Button variant="outline">Custom overlay</Button>
    </DialogTrigger>
    <DialogContent
      presentation="slot"
      class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4"
    >
      <div class="max-w-sm rounded-lg border bg-background p-6 shadow-lg">
        <p class="text-sm">Your panel markup only — single portaled root.</p>
        <DialogClose asChild>
          <Button class="mt-4" variant="outline">
            Close
          </Button>
        </DialogClose>
      </div>
    </DialogContent>
  </Dialog>
);

Demo

Keep a Short Editing Task in Context. Place the related fields in FieldGroup beneath the dialog's title and description. The modal provides a focused editing context; your form still owns the values, validation and behavior of its save action.

Connect labels and errors to the fields, choose explicit submit and cancel behavior, and decide whether closing should discard unsaved values before copying the demonstration handlers.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Basic

Establish the Dialog's Purpose First. Start with DialogTitle and DialogDescription to give the opened panel a clear purpose and explanation. This minimal composition makes naming and dismissal easier to inspect before adding forms or secondary actions.

Keep the content focused on one task and preserve a discoverable way to close it; use Alert Dialog for a consequential confirmation rather than ordinary supporting information.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Custom Close

Make Dismissal Fit the Task. Set showCloseButton={false} when a clearly labeled footer control should provide the visible dismissal action. The custom button becomes part of the dialog's reading order rather than competing with an additional corner control.

Give that control an explicit label and retain the primitive's keyboard behavior; removing the standard corner button should not leave users guessing how to return.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

No Close Button

Replace the Missing Affordance Intentionally. Hiding the corner button with showCloseButton={false} changes the visible controls, not the need for a way out. Supply an understandable alternative inside the panel and preserve the dialog's expected keyboard dismissal behavior.

Check cancellation, Escape behavior and focus return, and avoid using a hidden close control as a substitute for proper pending-state handling.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Scrollable Content

Constrain Long Content to a Readable Region. Give long dialog content its own constrained scroll region beneath the header. This keeps the title available as context while allowing the reader to reach the full explanation without extending the modal beyond the viewport.

Test keyboard scrolling, links near the end and narrow screens, and consider a full page when the content grows into a multi-step or reference-heavy workflow.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Destructive Actions

Keep Confirmation Specific to the Pending Operation. Place a cancel action beside a clearly labeled destructive confirmation in the footer. The visual hierarchy should distinguish leaving the dialog from executing the operation while the description explains what the confirmation affects.

If the panel only asks users to confirm a risky decision, compare Alert Dialog before building a custom confirmation flow inside a general dialog.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Dialog using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props, slots and variants for this component.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/dialog36.2 KB min · 8.8 KB gzipSignals: direct@preact/signals

Dialog

DialogProps

Dialog documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDialogProps

Configure children for Dialog. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
defaultOpen
booleanDialogProps

Configure defaultOpen for Dialog. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
dismissible
booleanDialogProps

When false, Escape and an overlay click leave the dialog open. An explicit close control still closes it. Default true.

Default
true
lockBodyScroll
booleanDialogProps

When true, locks document scroll while open (shadcn default).

Default
true
onOpenChange
((open: boolean) => void)DialogProps

Configure onOpenChange for Dialog. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
open
booleanDialogProps

Configure open for Dialog. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DialogClose

DialogCloseProps

DialogClose documented props
Prop / typeDescription
asChild
booleanDialogCloseProps

Configure asChild for DialogClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
children
ComponentChild[] | ComponentChildDialogCloseProps

Configure children for DialogClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringDialogCloseProps

Configure data-slot for DialogClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onClick
MouseEventHandler<HTMLButtonElement>DialogCloseProps

Configure onClick for DialogClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
ref
Ref<HTMLButtonElement>DialogCloseProps

Configure ref for DialogClose. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DialogContent

DialogContentProps

DialogContent documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDialogContentProps

Configure children for DialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>DialogContentProps

Configure class for DialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringDialogContentProps

Configure data-slot for DialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
forceMount
booleanDialogContentProps

Configure forceMount for DialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
getInitialFocus
((panel: HTMLElement) => HTMLElement | null | undefined)DialogContentProps

Override the default focus target when the modal opens (for example AlertDialog cancel).

Default
—
onKeyDown
KeyboardEventHandler<HTMLDivElement>DialogContentProps

Configure onKeyDown for DialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
presentation
DialogContentPresentationDialogContentProps

`modal` — built-in overlay + centered panel + optional corner close. `slot` — one portaled element only; use when **you** provide overlay + panel (legacy fullscreen `DialogContent` pattern with `fixed inset-0 …`).

Default
"modal"
role
((AriaRole | SignalLike<AriaRole | undefined>) & ("alertdialog" | "dialog"))DialogContentProps

Configure role for DialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"dialog"
showCloseButton
booleanDialogContentProps

Configure showCloseButton for DialogContent. Compare its accepted type with the Usage Guidance before supplying a value.

Default
true

DialogDescription

DialogDescriptionProps

DialogDescription documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDialogDescriptionProps

Configure children for DialogDescription. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>DialogDescriptionProps

Configure class for DialogDescription. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
id
string | SignalLike<string | undefined>DialogDescriptionProps

Configure id for DialogDescription. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DialogFooter

DialogFooterProps

DialogFooter documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDialogFooterProps

Configure children for DialogFooter. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>DialogFooterProps

Configure class for DialogFooter. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DialogHeader

DialogHeaderProps

DialogHeader documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDialogHeaderProps

Configure children for DialogHeader. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>DialogHeaderProps

Configure class for DialogHeader. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DialogPortal

DialogPortalProps

DialogPortal documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDialogPortalProps

Configure children for DialogPortal. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
forceMount
booleanDialogPortalProps

Keep the portal mounted while exit animations run.

Default
false

DialogTitle

DialogTitleProps

DialogTitle documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildDialogTitleProps

Configure children for DialogTitle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
string | SignalLike<string | undefined>DialogTitleProps

Configure class for DialogTitle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
id
string | SignalLike<string | undefined>DialogTitleProps

Configure id for DialogTitle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

DialogTrigger

DialogTriggerProps

DialogTrigger documented props
Prop / typeDescription
asChild
booleanDialogTriggerProps

Configure asChild for DialogTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
children
ComponentChild[] | ComponentChildDialogTriggerProps

Configure children for DialogTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
data-slot
stringDialogTriggerProps

Configure data-slot for DialogTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onClick
MouseEventHandler<HTMLButtonElement>DialogTriggerProps

Configure onClick for DialogTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onPointerDown
PointerEventHandler<HTMLButtonElement>DialogTriggerProps

Configure onPointerDown for DialogTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
ref
Ref<HTMLButtonElement>DialogTriggerProps

Configure ref for DialogTrigger. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

DialogContextValue

7 declared fields
DialogContextValue
Exported Source Declaration from Dialog.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogContextValue before adapting it.
Required fields
open, setOpen, triggerRef, layerRootRef, defaultTitleId, defaultDescriptionId, dismissible

Dialog Props

6 declared fields
DialogProps
Exported Source Declaration from Dialog.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogProps before adapting it.

DialogClose Props

3 declared fields
DialogCloseProps
Exported Source Declaration from DialogClose.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogCloseProps before adapting it.
DialogContentPresentation
Exported Source Declaration from DialogContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogContentPresentation before adapting it.

DialogContent Props

7 declared fields
DialogContentProps
Exported Source Declaration from DialogContent.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogContentProps before adapting it.

DialogDescription Props

1 declared field
DialogDescriptionProps
Exported Source Declaration from DialogDescription.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogDescriptionProps before adapting it.

DialogFooter Props

1 declared field
DialogFooterProps
Exported Source Declaration from DialogFooter.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogFooterProps before adapting it.

DialogHeader Props

1 declared field
DialogHeaderProps
Exported Source Declaration from DialogHeader.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogHeaderProps before adapting it.

DialogPortal Props

2 declared fields
DialogPortalProps
Exported Source Declaration from DialogPortal.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogPortalProps before adapting it.

DialogTitle Props

1 declared field
DialogTitleProps
Exported Source Declaration from DialogTitle.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogTitleProps before adapting it.

DialogTrigger Props

3 declared fields
DialogTriggerProps
Exported Source Declaration from DialogTrigger.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogTriggerProps before adapting it.

DialogLabelParts

4 declared fields
DialogLabelParts
Exported Source Declaration from dialogLabelParts.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DialogLabelParts before adapting it.
Required fields
hasTitle, hasDescription

Accessibility

Build the Complete Interaction, Including the Parts Outside Dialog. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.

Built-in Behavior and Defaults

DialogContent supplies a modal dialog surface, focus containment, Escape dismissal and return focus. DialogTitle and DialogDescription connect its accessible name and description. The default modal presentation includes its own overlay and close control.

Labels and Relationships

Use a title describing the task, followed by a concise explanation where useful. For long structured content, avoid turning every paragraph into one lengthy accessible description. Keep normal headings, labels and reading order inside the dialog.

Use the Built-in Title and Description Relationship. The trigger uses a real button and the dialog keeps its default close control. Add the actual task controls inside the content and verify initial focus for that task.

Usage PatternTypeScript
import {
  Button, Dialog, DialogTrigger, DialogContent,
  DialogHeader, DialogTitle, DialogDescription,
} from "@kamod-ch/ui";

export function ExportDetails() {
  return (
    <Dialog>
      <DialogTrigger asChild><Button type="button">Export details</Button></DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>About this export</DialogTitle>
          <DialogDescription>The export includes the currently visible records.</DialogDescription>
        </DialogHeader>
      </DialogContent>
    </Dialog>
  );
}

Keyboard and Focus

Open from a meaningful trigger, verify initial focus, then test forward and reverse Tab navigation and Escape. When the trigger disappears after a successful action, your application must choose a sensible surviving focus destination.

States and Integration Details

Use presentation="slot" only when deliberately providing the custom surface the API expects. Avoid nesting a second modal shell around the content. If hiding the default close control, retain another clear, keyboard-operable way to dismiss.

Verify the Complete Interaction

Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.

  1. Open, traverse and close without a pointer; confirm focus does not escape into the background.
  2. Inspect the dialog's name and description, including content with long text or validation errors.
  3. Submit, dismiss and remove the opener in separate flows; verify return focus and body scrolling recover.

Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.

For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.