```ts import Modal from "~/components/ui/Modal.vue" ``` # Modal | Prop | Data type | Required? | Default | Description | | --------- | ----------------- | --------- | ------- | ---------------------------------- | | `title` | `string` | Yes | | The modal title | | `v-model` | `true` \| `false` | No | | Whether the modal is isOpen or not | ```vue-html Modal content ```
Modal content
## Add actions Use the `#actions` slot to add actions to a modal. Actions typically take the form of [buttons](./button). Make sure to add `autofocus` to the preferred button. ```vue-html Modal content ```
Modal content
### Add a cancel button All modals can be closed so it makes sense to add a `cancel` button. Note that `Modal` also implements the `ESC` shortcut by default. The `cancel` prop accepts a string and will add a cancel button. Note that the Cancel button has `autofocus`. If you want another button to auto-focus, implement the Cancel button manually inside the `#action` slot. ## Customize the title bar Use the `icon` prop and/or the `#topleft` slot for indicators such as the user's photo or a search input. You can hide the title by setting it to `""`. No information pages found for {{ input }} ## Add a main alert You can nest [Funkwhale alerts](./alert) to visually highlight content within the modal. ```vue-html Modal content ```
Modal content
## Confirm a dangerous action Note that confirmation dialogs interrupt the user's workflow. Consider adding a recovery functionality such as "undo" instead. ::: tip Read more about designing user experiences around dangerous actions: - [How to use visual signals and spacing to differentiate between benign and dangerous options](https://www.nngroup.com/articles/proximity-consequential-options/) > If you need to implement dangerous actions, make sure to place them apart from other actions to prevent accidental clicks. Add contextual hints and information so that the user understands the consequences of the action. - [How to design a confirmation dialog](https://www.nngroup.com/articles/confirmation-dialog/) > 1. Let the user confirm potentially destructive actions > 2. Do not use confirmation dialogs for routine tasks > 3. Be specific about the action and its potential consequences > 4. Label the response buttons with their result: "Delete my account" instead of "Yes" > 5. Make sure to give the user all information they need to decide ::: ### Destructive Modal The `destructive` prop is used to visually indicate a potentially dangerous or irreversible action. When set to `true`, the modal will have a distinctive red styling to draw the user's attention and highlight the critical nature of the action. | Prop | Data type | Required? | Default | Description | | ------------- | --------- | --------- | ------- | ---------------------------------------------------- | | `destructive` | `true` | No | `false` | Applies a red styling to emphasize dangerous actions | ### Styling Effects When the `destructive` prop is set to `true`, the modal will: - Add a red border - Style the title in red To visually distinguish the modal from standard modals ### Best Practices - Use the `destructive` prop sparingly - Clearly explain the consequences of the action using `` - Provide a clear way to cancel the action. If you use the `cancel` prop, the Cancel button will have autofocus, preventing accidental confirmation. - Use descriptive action button labels The example in the "Confirm a dangerous action" section demonstrates the recommended usage of the destructive modal. ```vue-html ``` ## Nested modals You can nest modals to allow users to isOpen a modal from inside another modal. This can be useful when creating a multi-step workflow. ```vue-html Nested modal content ```
Nested modal content
## Auto-focus the close button If there are no action slots and no cancel button, the close button is auto-focused. The `autofocus` prop, when set to `off`, overrides this behavior. ## Responsivity ### Designing for small screens On slim phones, with the default 32px paddings, the content may only be 260px wide (Galaxy S5). Make sure the content wraps accordingly.