Modal
A centered overlay dialog for content that needs the user's attention before they continue. It has no corner close button and closes only through actions inside it.
Usage
Modal displays content that temporarily blocks interaction with the rest of the application. Modals are interruptive, so use them with care.
<Modal opened={opened} onClose={() => setOpened(false)} title="Slett rad" size="md">
<FocusTrap.InitialFocus />
<Text size="md" mb="md">Denne handlingen kan ikke angres.</Text>
<TextInput label="Kommentar" mb="md" />
<Checkbox label="Jeg bekrefter at raden skal slettes" mb="md" />
<Group justify="flex-end">
<Button variant="secondary" onClick={() => setOpened(false)}>Avbryt</Button>
<Button variant="primary" onClick={() => setOpened(false)}>Slett</Button>
</Group>
</Modal>
size
You can change the modal width by setting the size prop to a predefined size or any valid width, for example, 55% or 50rem. The Modal width cannot exceed 100vw.
Fullscreen
A fullscreen modal will take the entire screen. Use this carefully because it's hard for users to understand that this is a modal when there is little UI feedback.
Props
Only what this design system changes. Everything else is Mantine's — read the full props table there.
| Property | Type | Allowed values | Default | Description |
|---|---|---|---|---|
withCloseButton | boolean | — | false | Renders the corner close button. Mantine ships it on. |
closeOnClickOutside | boolean | — | false | Closes the modal when the overlay is clicked. Mantine ships it on. |
closeOnEscape | boolean | — | false | Closes the modal on Escape. Mantine ships it on. |
centered | boolean | — | true | Centres the modal vertically in the viewport rather than anchoring it near the top. |
radius | MantineRadius | number | — | md | Rounds the modal corners to 8px, overriding the theme's own global default of sm (5px). |
title | ReactNode | — | — | Heading in the modal header, rendered at the h4 size (20px). |
transitionProps | TransitionProps | — | { transition: 'pop', duration: 300, timingFunction: 'ease' } | Sets how the modal enters and leaves. Dropdowns use a separate, faster transition. |
Not touched: trapFocus and returnFocus both keep Mantine's own default of
true.
Accessibility
- Closing. The corner close button, click on the overlay and Escape are off by default. The modal closes through an action you provide inside it, such as the footer buttons in the demo above.
- Initial focus. Mantine focuses the first focusable element inside the
modal on open. With
withCloseButtonoff, that is the first interactive element in the body or footer. UseFocusTrap.InitialFocus, as in the demo, to start focus on the modal itself instead. - Focus is trapped inside the modal while it is open and returned to the
trigger element on close (
trapFocus,returnFocus— both Mantine defaults, untouched here).