Composition
This component is a composition of 6 key components:
- LumexModal: A component representing a modal dialog overlay.
- LumexModalTrigger: A component representing the trigger that controls the modal display.
- LumexModalContent: A component representing the content container of the modal.
- LumexModalHeader: A component representing the header of the modal.
- LumexModalBody: A component representing the body of the modal.
- LumexModalFooter: A component representing the footer of the modal.
Usage
The modal is built on top of the native HTML <dialog> element.
This means you can use the command="close" and commandfor
attributes on any button element to close the modal declaratively.
<button> element to work, so use the
LumexButton component. Alternatively, you can call
@context.CloseAsync() to close the modal programmatically.
Sizes
Use Size parameter to control the maximum width of the modal.
Radius
Use Radius parameter to control the border radius of the modal.
Shadows
Use Shadow parameter to control the shadow depth of the modal.
Backdrop
Use Backdrop parameter to change the backdrop style behind the modal.
Custom Backdrop
Use the Class parameter to apply a custom gradient backdrop to the modal.
Placement
Use Placement parameter to control the position of the modal within the viewport.
Auto placement positions the modal at the bottom on mobile screens
and at the center on larger screens.
Scroll behavior
Use ScrollBehavior parameter to control how the modal handles overflow content.
With form
The modal body can contain form elements such as inputs, checkboxes, and links.
Close methods
There are multiple ways to close the modal. Use command="close" with
commandfor="@context.Id" for a declarative approach, or call
@context.CloseAsync() for programmatic control.
Two-way data binding
Use @bind-Open directive or Open and OpenChanged
parameters to programmatically control the modal's open state.
Custom styles
This component supports named slots, which allow custom styles to be applied to specific parts of the component:
- Base: The base container of the modal dialog.
- Header: The header section of the modal.
- Body: The body section of the modal.
- Footer: The footer section of the modal.
- CloseButton: The close button element of the modal.
You can customize the component(s) by passing any Tailwind CSS classes to the following component parameters:
Modal
Class: The CSS class name that styles the base of the modal.Classes: The CSS class names for the modal slots that style entire modal.
API
See the API references below for a complete guide to all the parameters available for the components mentioned here.