Navigated to /docs/ui/dialogs-and-floating-content

Dialogs and floating content

Understand open state, focus, dismissal, keyboard navigation, positioning, and announcements across floating interfaces.

Dialog and confirmation behavior

  • Dialog defaults open=false, fullScreen=false, and closeLabel=Close. A closed Dialog renders no DOM.

  • The open dialog uses role=dialog, aria-modal=true, tabIndex=-1, Escape closing, and Tab focus trapping.

  • Clicking the overlay calls onClose. An application onClick handler can preventDefault to keep it open.

  • Use labelledBy and describedBy for stable title and description relationships. Passing title without labelledBy displays a title but does not invent an ID.

  • ConfirmDialog defaults title to Confirm action, labels to Confirm and Cancel, and tone to danger. Both actions are application callbacks.

TSX
tsximport { Dialog, Text } from "@tavojs/ui";

<Dialog open={open} title="Invite teammate" labelledBy="invite-title" describedBy="invite-help" onClose={close}>
  <Text id="invite-help">Choose an account role before sending.</Text>
</Dialog>

Sheets and menus

  • Sheet defaults open=false and side=right. Its Content repeats open and side because the compound API does not share hidden component state.

  • Sheet.Content uses dialog semantics, Escape closing, and focus trapping. Sheet.Close defaults its accessible label to Close sheet.

  • DropdownMenu uses native details/summary structure, defaults open=false and align=end, and closes through onClose when Escape is pressed.

  • Menu items support ArrowUp, ArrowDown, Home, and End focus movement. An href item is a link; another item is a button.

  • A disabled link item removes href, sets aria-disabled, and uses tabIndex=-1.

Popovers and disclosures

  • Popover defaults open=false and placement=bottom-start. Placement supports bottom-start, bottom-end, top-start, and top-end.

  • Popover.Content uses a directive to stay within an eight-pixel viewport margin, update on resize and scroll, and close its native details owner after an outside pointer press.

  • A custom use directive on Popover.Content is merged with the positioning directive rather than replacing it.

  • Collapsible is a styled native details element with Root, Trigger, and Content members. open defaults to false.

  • Tooltip defaults side=top and exposes role=tooltip. HoverCard uses focusable trigger and tooltip content but does not own application state.

Focus and announcement helpers

  • FocusTrap defaults active to true and cycles Tab or Shift+Tab within its descendants. It does not create dialog semantics or restore focus by itself.

  • Spinner defaults size=md, tone=primary, and label=Loading; it exposes status semantics.

  • Toast defaults tone=info and closeLabel=Dismiss notification. ToastStack only positions a group; application state owns its queue and removal.

  • Overlay defaults open=true, scrim=soft, and center=true. It is a visual primitive, not a modal or focus manager.