` element. [Docs][
## ModalFooter
+ModalFooter is the place for actions represented by the Button component. While there always must be a primary Button,
+secondary actions are optional.
+
+👉 Please note the actions are _visually_ ordered from right to left from the tablet breakpoint up. However, the
+_actual_ order in code is followed when users tab over the interface.
+
+```jsx
+
+ Primary action
+ Secondary action
+
+```
+
+### Footer Description
+
+Optionally, you can add a description into the footer:
+
+```jsx
+
…
+```
+
+### Footer Alignment
+
+ModalFooter can be aligned to the right (default), center, or left. These values come from the
+[dictionary][dictionary-alignment]. Using a corresponding alignment option will align the footer actions accordingly:
+
+- `right` (default)
+- `center`
+- `left`
+
+```jsx
+
…
+```
+
### API
| Name | Type | Default | Required | Description |
| ------------------ | --------------------------------------------- | ------- | -------- | ----------------------------- |
| `alignmentX` | [AlignmentX dictionary][dictionary-alignment] | `right` | ✕ | ModalFooter alignment |
| `children` | `ReactNode` | — | ✕ | Children node |
+| `description` | `string` | `null` | ✕ | Optional Footer Description |
| `UNSAFE_className` | `string` | — | ✕ | ModalFooter custom class name |
| `UNSAFE_style` | `CSSProperties` | — | ✕ | ModalFooter custom style |
The rest of the properties are based from type of `HTMLElement`. [Docs][HTMLElementDocs]
+## Opening the Modal
+
+Use a hook to open your Modal, e.g.:
+
+```jsx
+const [isOpen, setOpen] = useState(false);
+const toggleModal = () => setOpen(!isOpen);
+const handleClose = () => setOpen(false);
+
+
+ Open Modal
+ ;
+```
+
## Scrolling Long Content
When Modals become too long for the user's viewport or device, they automatically scroll independent of the page itself.
+### Scrolling with ScrollView
+
To make content overflow more obvious to users, you can wrap the `ModalBody` content in a [ScrollView][scroll-view] that
takes over the responsibility for scrolling and provides visual overflow decorators, e.g.:
@@ -142,6 +244,51 @@ takes over the responsibility for scrolling and provides visual overflow decorat
```
+## Full Example
+
+When you put it all together:
+
+```jsx
+import {
+ Button,
+ Modal,
+ ModalBody,
+ ModalDialog,
+ ModalFooter,
+ ModalHeader,
+ ScrollView,
+} from '@lmc-eu/spirit-web-react/components';
+
+const [isOpen, setOpen] = useState(false);
+const toggleModal = () => setOpen(!isOpen);
+const handleClose = () => setOpen(false);
+
+
+ Open Modal
+
+
+
+
+ Title of the Modal
+
+ Modal body
+
+
+
+ Submit
+
+
+ Cancel
+
+
+
+
+```
+
[DialogElementDocs]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog
[ArticleElementDocs]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article
[FormElementDocs]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
diff --git a/packages/web-twig/src/Resources/components/Modal/README.md b/packages/web-twig/src/Resources/components/Modal/README.md
index f2c9af59d9..ecdce1935e 100644
--- a/packages/web-twig/src/Resources/components/Modal/README.md
+++ b/packages/web-twig/src/Resources/components/Modal/README.md
@@ -12,19 +12,17 @@ Modal is a composition of several subcomponents:
## Modal
-### Examples:
+Modal establishes the top layer with backdrop. Under the hood it uses the [`
` element][mdn-dialog] which
+provides several accessibility advantages.
```twig
-
- …
-
…
```
-👉 Please note the `titleId` attribute is linked to the title inside
-[Modal Header](#modalheader) and provides an accessible name for the dialog.
+👉 Please note the `titleId` attribute is linked to the title inside [Modal Header](#modalheader) and provides an
+accessible name for the dialog.
### API
@@ -40,21 +38,73 @@ These attributes will be passed to the topmost HTML element of the component.
## ModalDialog
-ModalDialog is the actual dialog window, a place for the header, body, and
-footer of the dialog.
-
-### Examples:
+ModalDialog is the actual dialog window, a place for the header, body, and footer of the dialog.
```twig
…
+```
+
+### Forms in Modal
-
+Modal can also contain interactive content like forms. For such cases, you may find convenient to use the `
```
-👉 Even in cases you don't need the title to be visible you should provide an
-accessible name for the dialog, e.g. using the `aria-label` attribute:
+### Hidden Title
+
+👉 Even in cases you don't need the title to be visible you should provide an accessible name for the dialog, e.g. using
+the `aria-label` attribute on the `