Dialog

Dialogs display important information that users need to acknowledge. They appear over the interface and block further interactions.

installyarn add @react-spectrum/dialog
version3.0.0-alpha.1
usageimport {Dialog} from '@react-spectrum/dialog'

Example#


<DialogTrigger>
  <ActionButton>Trigger</ActionButton>
  {(close) => (
    <Dialog>
      <Header><Heading>The Heading</Heading></Header>
      <Divider />
      <Content>
        <Text>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sit amet tristique risus. In sit amet suscipit lorem. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In condimentum imperdiet metus non condimentum. Duis eu velit et quam accumsan tempus at id velit. Duis elementum elementum purus, id tempus mauris posuere a. Nunc vestibulum sapien pellentesque lectus commodo ornare.</Text>
      </Content>
      <Footer>
        <Button variant="secondary" onPress={close}>Cancel</Button>
        <Button variant="cta" onPress={close}>Confirm</Button>
      </Footer>
    </Dialog>
  )}
</DialogTrigger>

Content#


If the component has a children prop that accepts any type of content (e.g. ReactNode), include this section. Please include a note about how to internationalize the content.

Accessibility#

If the component has accessibility needs, include this section.

Internationalization#

If this component has content, cover how to internationalize the content, include this section.

Value#


If the component displays or allows a user to input a value, include this section.

Labeling#


If the component supports a label prop, include this section. Please include a note about how to internationalize the content.

Events#


If the component supports event props, include this section. Only cover the events that are important to the main functionality of the component.

Validation#


If the component supports validation props, include this section.

Props#


NameTypeDefaultDescription
childrenReactNodeThe contents of the Dialog.
size'S' | 'M' | 'L' | 'fullscreen' | 'fullscreenTakeover'The size of the Dialog. Only applies to "modal" type Dialogs.
isDismissablebooleanWhether the Dialog is dismissable.
UNSAFE_classNamestring
UNSAFE_styleCSSProperties
Events
NameTypeDefaultDescription
onDismiss() => void
Layout
NameTypeDefaultDescription
flexstringnumberboolean
flexGrownumber
flexShrinknumber
flexBasisnumberstring
alignSelf'auto' | 'normal' | 'start' | 'end' | 'flex-start' | 'flex-end' | 'self-start' | 'self-end' | 'center' | 'stretch'
justifySelf'auto' | 'normal' | 'start' | 'end' | 'flex-start' | 'flex-end' | 'self-start' | 'self-end' | 'center' | 'left' | 'right' | 'stretch'
flexOrdernumber
gridAreastring
gridColumnstring
gridRowstring
gridColumnStartstring
gridColumnEndstring
gridRowStartstring
gridRowEndstring
Spacing
NameTypeDefaultDescription
marginDimensionValue
marginTopDimensionValue
marginLeftDimensionValue
marginRightDimensionValue
marginBottomDimensionValue
marginStartDimensionValue
marginEndDimensionValue
marginXDimensionValue
marginYDimensionValue
Sizing
NameTypeDefaultDescription
widthDimensionValue
minWidthDimensionValue
maxWidthDimensionValue
heightDimensionValue
minHeightDimensionValue
maxHeightDimensionValue
Positioning
NameTypeDefaultDescription
position'static' | 'relative' | 'absolute' | 'fixed' | 'sticky'
topDimensionValue
bottomDimensionValue
leftDimensionValue
rightDimensionValue
startDimensionValue
endDimensionValue
zIndexnumber
isHiddenboolean
Accessibility
NameTypeDefaultDescription
role'dialog''alertdialog'
idstring
tabIndexnumber
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-controlsstringIdentifies the element (or elements) whose contents or presence are controlled by the current element.
aria-ownsstring

Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship between DOM elements where the DOM hierarchy cannot be used to represent the relationship.

aria-hiddenboolean'false''true'Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.

Visual Options#


Show examples of all variants and visual props here with links to the design website for more usage details. Examples can be grouped together for conciseness.

Sample Option#

View guidelines