Dialog
Dialogs display important information that users need to acknowledge. They appear over the interface and block further interactions.
install | yarn add @react-spectrum/dialog |
---|---|
version | 3.0.0-alpha.1 |
usage | import {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#
Name | Type | Default | Description |
children | ReactNode | — | The contents of the Dialog. |
size | 'S'
| 'M'
| 'L'
| 'fullscreen'
| 'fullscreenTakeover' | — | The size of the Dialog. Only applies to "modal" type Dialogs. |
isDismissable | boolean | — | Whether the Dialog is dismissable. |
UNSAFE_className | string | — | |
UNSAFE_style | CSSProperties | — |
Events
Name | Type | Default | Description |
onDismiss | () => void | — |
Layout
Name | Type | Default | Description |
flex | string | number | boolean | — | |
flexGrow | number | — | |
flexShrink | number | — | |
flexBasis | number | string | — | |
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' | — | |
flexOrder | number | — | |
gridArea | string | — | |
gridColumn | string | — | |
gridRow | string | — | |
gridColumnStart | string | — | |
gridColumnEnd | string | — | |
gridRowStart | string | — | |
gridRowEnd | string | — |
Spacing
Name | Type | Default | Description |
margin | DimensionValue | — | |
marginTop | DimensionValue | — | |
marginLeft | DimensionValue | — | |
marginRight | DimensionValue | — | |
marginBottom | DimensionValue | — | |
marginStart | DimensionValue | — | |
marginEnd | DimensionValue | — | |
marginX | DimensionValue | — | |
marginY | DimensionValue | — |
Sizing
Name | Type | Default | Description |
width | DimensionValue | — | |
minWidth | DimensionValue | — | |
maxWidth | DimensionValue | — | |
height | DimensionValue | — | |
minHeight | DimensionValue | — | |
maxHeight | DimensionValue | — |
Positioning
Name | Type | Default | Description |
position | 'static'
| 'relative'
| 'absolute'
| 'fixed'
| 'sticky' | — | |
top | DimensionValue | — | |
bottom | DimensionValue | — | |
left | DimensionValue | — | |
right | DimensionValue | — | |
start | DimensionValue | — | |
end | DimensionValue | — | |
zIndex | number | — | |
isHidden | boolean | — |
Accessibility
Name | Type | Default | Description |
role | 'dialog' | 'alertdialog' | — | |
id | string | — | |
tabIndex | number | — | |
aria-label | string | — | Defines a string value that labels the current element. |
aria-labelledby | string | — | Identifies the element (or elements) that labels the current element. |
aria-describedby | string | — | Identifies the element (or elements) that describes the object. |
aria-controls | string | — | Identifies the element (or elements) whose contents or presence are controlled by the current element. |
aria-owns | string | — | 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-hidden | boolean | '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.