Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Foundations

DialogBase

The native <dialog> for Cynosure, and the only module allowed to render one. It is a foundation: thin, unstyled, and meant to be built on by components rather than used in product code.

Who uses itLink to "Who uses it"

Dialog and Sheet.

When to use it directlyLink to "When to use it directly"

Only when you are building a new overlay that needs a native dialog with behaviour of its own and neither Dialog nor Sheet fits.

Open prop drives show modal and close

UsageLink to "Usage"

tsx
Copy
import { DialogBase } from "@arshad-shah/cynosure";

<DialogBase open={open} onCancel={() => setOpen(false)} onClose={() => setOpen(false)} aria-label="Preview">
  …
</DialogBase>

PropsLink to "Props"

It accepts every native dialog attribute except open, onCancel and onClose, which it owns.

Every prop of DialogBase
PropWhat it doesTypeDefault
openRequired
Shown while true: showModal() (or show() when not modal) and close() follow this prop.boolean
modal
Top layer with the rest of the page inert (default), or an ordinary non-modal dialog.boolean
onCancel
A close request (Escape, the Android back gesture). Its default is prevented so open stays in charge.(() => void)
onClose
The browser closed the dialog while open was still true (a close request it would not let us cancel).(() => void)

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

GuaranteesLink to "Guarantees"

  • open drives showModal() (or show() with modal={false}) and close(); never the open attribute.
  • A cancel event (Escape, the Android back gesture) has its default prevented and calls onCancel, so your state decides.
  • If the browser closes the dialog anyway (a close request it will not let the page cancel), onClose is called so your state can follow. A close you asked for is not reported.
  • The ref reaches the native <dialog>. No styling.
Cancel becomes on cancel and stays open

Dialog · Sheet

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog