Skip to content

Modal

Classic modal overlay to include any content you may need

Examples

Base

Show code

Component Prop

Show code

Teleport

Show code

Programmatically

Show code

Programmatically (with promises and async/await)

Show code

Class props

'Classes applied to the element'

Classic modal overlay to include any content you may need

html
<o-modal></o-modal>

Props

Prop nameDescriptionTypeValuesDefault
activeWhether modal is active or not, use v-model:active to make it two-way bindingboolean-false
animationCustom animation (transition name)string-
From config:
modal: {
  animation: "zoom-out"
}
ariaLabelAccessibility aria-label to be passed to the div wrapper elementstring-
From config:
modal: {
  ariaLabel: undefined
}
ariaRoleRole attribute to be passed to the div wrapper for better accessibility."alertdialog" | "dialog"dialog, alertdialog
From config:
modal: {
  ariaRole: "dialog"
}
autoFocusAutomatically focus modal when activeboolean-
From config:
modal: {
  autoFocus: true
}
cancelableIs Modal cancleable by clicking 'X', pressing escape or clicking outsideboolean | string[]escape, x, outside, button, true, false
From config:
modal: {
  cancelable: ["escape","x","outside"]
}
closeIconClose icon namestring-
From config:
modal: {
  closeIcon: "close"
}
closeIconSizeSize of close iconstringsmall, medium, large
From config:
modal: {
  closeIconSize: "medium"
}
componentComponent to be injected.
Close the component by emitting a 'close' event — $emit('close')
Component-
contentText content, unnecessary when default slot is usedstring-
eventsEvents to be binded to the injected component{}-
fullScreenDisplay modal as full screenboolean-false
mobileBreakpointMobile breakpoint as max-width valuestring-
From config:
modal: {
  mobileBreakpoint: undefined
}
overlayShow an overlayboolean-
From config:
modal: {
  overlay: true
}
overrideOverride existing theme classes completelyboolean-
propsProps to be binded to the injected componentany-
scrollUse clip to remove the body scrollbar, keep to have a non scrollable scrollbar to avoid shifting background,
but will set body to position fixed, might break some layouts.
"clip" | "keep"keep, clip
From config:
modal: {
  scroll: "keep"
}
teleportAppend the component to another part of the DOM.
Set true to append the component to the body.
In addition, any CSS selector string or an actual DOM node can be used.
boolean | object | string-
From config:
modal: {
  teleport: false
}
trapFocusTrap focus inside the modalboolean-
From config:
modal: {
  trapFocus: true
}
widthWidth of the Modalnumber | string-
From config:
modal: {
  width: 960
}

Events

Event namePropertiesDescription
update:activevalue boolean - updated active propactive prop two-way binding
closevalue unknown - close event dataon component close event

Slots

NameDescriptionBindings
defaultModal default content, default is content propclose (...args): void - function to close the component

Sass variables

Current theme ➜ Oruga

SASS VariableDefault
$modal-content-background-colorvar(--#{$prefix}white)
$modal-content-border-radiusvar(--#{$prefix}base-border-radius)
$modal-overlay-background-colorhsla(0, 0%, 4%, 0.86)
$modal-close-border-radiusvar( --#{$prefix}base-border-radius-rounded)
$modal-close-right20px
$modal-close-top20px
$modal-close-size32px
$modal-close-colorvar(--#{$prefix}white)
$modal-content-fullscreen-background-color#f5f5f5
$modal-content-max-heightcalc(100vh - 160px)
$modal-content-margin0 auto
$modal-zindex40

See ➜ 📄 Full scss file

Current theme ➜ Bulma

The theme does not have any custom variables for this component.

Current theme ➜ Bootstrap

The theme does not have any custom variables for this component.

Released under the MIT License.