Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.idea
.package-lock.json
.parcel-cache
.vscode
build-storybook.log
coverage
dist
Expand Down
8 changes: 5 additions & 3 deletions packages/react-aria-components/docs/Modal.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import {DialogTrigger, Modal, Dialog, Button, Heading, TextField, Label, Input}
position: absolute;
top: 0;
left: 0;
width: 100vw;
width: var(--page-width);
height: var(--page-height);
background: rgba(0 0 0 / .5);
z-index: 100;
Expand Down Expand Up @@ -246,10 +246,11 @@ import {ModalOverlay} from 'react-aria-components';
position: absolute;
top: 0;
left: 0;
width: 100%;
width: var(--page-width);
height: var(--page-height);
background: rgba(45 0 0 / .3);
backdrop-filter: blur(10px);
overflow: clip;

&[data-entering] {
animation: mymodal-blur 300ms;
Expand Down Expand Up @@ -421,11 +422,12 @@ A `Modal` can be targeted with the `.react-aria-Modal` CSS selector, or by overr

By default, `Modal` includes a builtin `ModalOverlay`, which renders a backdrop over the page when a modal is open. This can be targeted using the `.react-aria-ModalOverlay` CSS selector. To customize the `ModalOverlay` with a different class name or other attributes, render a `ModalOverlay` and place a `Modal` inside.

The `--page-height` and `--visual-viewport-height` CSS custom property will be set on the `ModalOverlay`, the latter of which you can use to set the height of the Modal to account for the virtual keyboard on mobile.
The `--page-height`, `--page-width`, `--visual-viewport-height` and `--visual-viewport-width` CSS custom properties will be set on the `ModalOverlay`, the latter of which you can use to set the size of the Modal to account for the virtual keyboard on mobile.

```css render=false
.react-aria-ModalOverlay {
position: absolute;
width: var(--page-width);
height: var(--page-height);
}

Expand Down
58 changes: 57 additions & 1 deletion packages/react-aria-components/stories/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import styles from '../example/index.css';
import {TextField} from '../src/TextField';
import './styles.css';


export default {
title: 'React Aria Components/Modal',
component: Modal
Expand Down Expand Up @@ -80,6 +79,63 @@ export const ModalExample: ModalStory = () => (
</DialogTrigger>
);

export const SheetExample: ModalStory = () => (
<div style={{display: 'flex', flexDirection: 'column'}}>
<div style={{display: 'flex', height: '100vh', alignItems: 'center', justifyContent: 'center'}}>
<DialogTrigger>
<Button>Open modal</Button>
<ModalOverlay
style={{
position: 'fixed',
zIndex: 100,
top: 0,
left: 0,
bottom: 0,
right: 0,
background: 'rgba(0, 0, 0, 0.5)'
}}>
<Modal
style={{
position: 'sticky',
left: 0,
width: '300px',
/* Extra padding to account for iOS floating browser UI. */
top: '-100px',
height: 'calc(100dvh + 200px)',
padding: '100px 0',
marginLeft: 'auto',
background: 'white',
outline: 'none',
backgroundColor: 'lightgray',
borderLeft: '1px solid black',
boxShadow: '-8px 0 20px rgba(0, 0, 0, 0.1)',
fontFamily: 'system-ui',
fontSize: '0.875rem'
}}>
<Dialog>
{({close}) => (
<form style={{display: 'flex', flexDirection: 'column'}}>
<Heading slot="title" style={{marginTop: 0}}>Sign up</Heading>
<label>
First Name: <input placeholder="John" />
</label>
<label>
Last Name: <input placeholder="Smith" />
</label>
<Button onPress={close} style={{marginTop: 10}}>
Submit
</Button>
</form>
)}
</Dialog>
</Modal>
</ModalOverlay>
</DialogTrigger>
</div>
<div style={{height: '100vh'}} />
</div>
);

function InertTest() {
return (
<DialogTrigger>
Expand Down
3 changes: 2 additions & 1 deletion starters/docs/src/Modal.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
position: absolute;
top: 0;
left: 0;
width: 100vw;
width: var(--page-width);
height: var(--page-height);
background: rgba(0 0 0 / .5);
overflow: clip;
z-index: 100;
font-family: system-ui;
font-size: var(--font-size);
Expand Down
3 changes: 2 additions & 1 deletion starters/docs/src/Sheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
position: absolute;
top: 0;
left: 0;
width: 100%;
width: var(--page-width);
height: var(--page-height);
background: rgba(0 0 0 / .3);
backdrop-filter: blur(10px);
z-index: 100;
overflow: clip;

&[data-entering] {
animation: sheet-blur 300ms;
Expand Down
Loading