logoRuru UI

Modal

The Modal component is used to display content in a modal dialog.

Installation

npx ruru-ui-cli@latest add modal

Usage

Here is an example of how to use the Modal component.

Example

The Modal component can be used with a custom trigger button.

Single button

The Modal component can be used with a single button.

Disabled actions

The Modal component can be used with disabled actions.

The Modal component can be used with a custom width.

Preview Component

The component that you see on preview

Animation Variants

The Modal component supports multiple animation variants for opening and closing. You can set the animation variant by passing the animationVariant prop to the Modal component.

Props

Here's how the props table would look for the Modal component, formatted in the same style:

NameTypeDefaultDescription
childrenReactNodeundefinedThe children of the Modal component.
onClickOutside() => voidundefinedThe function to call when the user clicks outside the modal.
animationVariant"default" | "fade" | "zoom" | "scaleBounce" | "slideUp" | "slideDown" | "slideRight" | "slideLeft" | "flip" | "rotate""default"Specifies the animation style for opening and closing the modal. Each variant provides a different visual effect.

ModalAction

NameTypeDefaultDescription
fullWidthbooleanfalseDetermines if the action button should take the full width.
onClick() => void | Promise<void>undefinedThe function to call when the user clicks the action.

Trigger

NameTypeDefaultDescription
childrenReactNodeundefinedThe children of the Modal component.
onClick() => voidundefinedThe function to call when the user clicks the trigger.
asChildbooleanfalseRender as a child component.

DivProps

NameTypeDefaultDescription
classNamestring""Additional class names for the container.
childrenReactNodeundefinedThe children of the component.

PTagProps

NameTypeDefaultDescription
classNamestring""Additional class names for the paragraph element.
childrenReactNodeundefinedThe children of the paragraph element.

On this page