Recipes
04
FormDialog
Modal form with a focus trap and Escape-to-close, built on the animation layer’s [data-state] overlay.
rendered by aura-react
rendered by aura-react
rendered by aura-react
rendered by aura-react
rendered by aura-react
Code
Demo.tsx
import { useState } from 'react';
import { Button, Dialog, Field, Group } from '@ilomee/aura-react';
// A form dialog is a Dialog with a form in it. `Dialog` owns the scrim, the focus trap, the
// scroll lock and Escape; the form and its two buttons are the part that was ever specific to
// this screen, which is why the recipe that wrapped them is an example rather than a component.
export default function Demo() {
const [open, setOpen] = useState(true);
const [name, setName] = useState('');
return (
<>
<Button variant="primary" onClick={() => setOpen(true)}>
New workspace
</Button>
<Dialog
open={open}
onClose={() => setOpen(false)}
title="New workspace"
autoFocus={false}
withCloseButton
>
<form
onSubmit={(e) => {
e.preventDefault();
setOpen(false);
}}
>
<Field label="Name" value={name} onValueChange={setName} placeholder="Acme" />
<Group style={{ marginTop: 20, justifyContent: 'flex-end' }}>
<Button type="button" onClick={() => setOpen(false)}>
Cancel
</Button>
<Button type="submit" variant="primary" disabled={!name}>
Create
</Button>
</Group>
</form>
</Dialog>
</>
);
}This is an example, not a component — no package ships it, and there is nothing to import. It is built from primitives that each of the four packages does ship, so the same composition works in every stack; copy it into your own component and it is yours to change.
Props
No props: the composition takes what you give the primitives inside it. Their props are on their own pages.
Emitted classes
Every framework emits the same classes — that is what makes the four libraries look identical. You can use them directly, without any component library.
| Class | Role | Notes |
|---|---|---|
| .aura-overlay | base | Required. A modifier does nothing without it. |
| .aura-popup | base | Required. A modifier does nothing without it. |