Lapikit

Modal component

Modal

The Modal component displays an overlay panel above the main content. It is designed for dialogs, contextual messages, forms or alerts requiring direct interaction.

The modal can be centered, fixed at the top or bottom of the screen, and closes in different ways depending on the options activated (outside click, Escape key, etc.).

Examples of modal

Base

A simple example of modal control with an open variable. It is displayed at the center of the screen with a default size.

Contain

This example shows the contain option, which allows long content to be contained in a scrollable zone, ideal for modals with lots of text or forms.

Size

Prop size lets you control the overall size of the modal: from xs to full, depending on how much space you want to give it.

Density

The density option adjusts internal spacing. compact reduces margins and paddings, while comfortable adds air, for a more spacious look.

Position

You can position the modal at the top, center (default) or bottom of the screen. This example shows all three options.

Persistent

When persistent is enabled, the modal is not closed by clicking outside or pressing Escape. Perfect for cases where confirmation is mandatory.

Keyboard

By enabling closeWithEsc, the modal can be closed with the Escape key. This example illustrates this keyboard interaction.

Stacking

Several modals can be displayed at the same time, stacked. This example shows how to correctly manage z-indexes and focus between multiple windows.

API Reference

propstypedescriptiondefaulttype_extend
ref $bindableHTMLElementDirect access to DOM elementundefined
open $bindablebooleanControls component opening/closingfalse
darkbooleanEnable dark theme for component.false
lightbooleanEnable light theme for the component.false
colorstringApplies a custom color to text or icons.undefined
backgroundstringApply a custom background color.undefined
densityenumControls vertical densitydefaultcompact | comfortable | default
roundedstringControls item rounding (none, sm, md, lg, etc.).md
sizeenum | {enum: enum}Determines the size of the Modalmdxs | sm | md | lg | xl | full
persistentbooleanPrevent closing by clicking outside or with Escape.false
positionenumVertical position of content on screencenterbottom | center | top
containbooleanIf enabled, limits content to a container with internal scrollingfalse
closeWithEscbooleanClose the Modal with the Escape keyfalse

Variables CSS

variabledefaultdescription
–-modal-color–-kit-on-surfaceText color
–-modal-background–-kit-surfaceBackground color
–-modal-radius--kit-radius-mdModal edge radius
–-modal-translate-x-50%Horizontal position
–-modal-translate-y-50%Vertical position

Complement the use of Modals with Dialog for confirmations or Popover for light details.

©2025 Lapikit.

Made with by Nycolaide