Modal
A modal works best for focusing users' attention on a short amount of content and getting them to make a decision. Use it to temporarily interrupt a userβs current task and block interactions to the content below it.
If your modal content is more complex, or requires considerable time to complete, consider using an EuiFlyout instead.
Each EuiModal requires a specific set of nested child components. They can be omitted if necessary, but the order cannot be changed or interrupted.
Modals come a wrapping EuiOverlayMask to obscure the content beneath, but unlike flyouts, modals cannot be dismissed by clicking on the overlay mask. This is inline with our modal usage guidelines which requires there to be a primary action button, even if that button simply closes the modal.
Forms in a modal
Since the child components of EuiModal are required to be in a specific order, you can only wrap the contents within EuiModalBody with the <form />
element. You can then hook up your submit button inside EuiModalFooter by adding the id
of the <form />
element to the form
prop of the button.
Confirm modal
Use the EuiConfirmModal to ask the user to confirm a decision. It is a contextual wrapper around EuiModal that provides some helpful props for filling in common modal pieces. By default, the button color indicates a positive or neutral action. Change the buttonColor
property to danger
to indicate a destructive action.
Loading and disabling confirm button
EuiConfirmModal supports being able to apply loading and disabled states to the confirm button with the confirmButtonDisabled
and isLoading
props respectively. This is helpful to indicate the fetching of data and/or to wait for a user's input before enabling the confirm action.
Widths
Modals start with a minimum width of 400px
, just enough to display form rows. They will grow to fit the contents until it reaches the specified maxWidth
, the default of which is set to the medium breakpoint.
If the modal is not growing wide enough to fit your contents, you can pass a specific style.width
, just remember that modals will always shrink to fit the window width.
Props
EuiModal
Prop | Description and type | Default value |
---|---|---|
Prop children# | Description and type ReactNode to render as this component's content ReactNode | Default value Required |
Prop onClose# | Description and type Type: (event?: any) => void | Default value Required |
Prop className# | Description and type Type: string | Default value |
Prop maxWidth# | Description and type Sets the max-width of the modal. string | number | boolean | Default value true |
Prop initialFocus# | Description and type Specifies what element should initially have focus. string | HTMLElement | (() => HTMLElement) | Default value |
Prop role# | Description and type Identifies a modal dialog to screen readers. Modal dialogs that confirm destructive actions "dialog" | "alertdialog" | Default value dialog |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
EuiModalHeader
Prop | Description and type | Default value |
---|---|---|
Prop className# | Description and type Type: string | Default value |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
EuiModalHeaderTitle
Prop | Description and type | Default value |
---|---|---|
Prop size# | Description and type Type: "xs" | "s" | "m" | "l" | "xxxs" | "xxs" | Default value |
Prop className# | Description and type Type: string | Default value |
Prop id# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop textTransform# | Description and type Type: "uppercase" | Default value |
Prop component# | Description and type The tag to render. Can be changed to a lower heading ElementType | Default value h1 |
EuiModalBody
Prop | Description and type | Default value |
---|---|---|
Prop className# | Description and type Type: string | Default value |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
EuiModalFooter
Prop | Description and type | Default value |
---|---|---|
Prop className# | Description and type Type: string | Default value |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
EuiConfirmModal
Prop | Description and type | Default value |
---|---|---|
Prop onCancel# | Description and type Type: (event?: any) => void | Default value Required |
Prop children# | Description and type ReactNode to render as this component's content ReactNode | Default value |
Prop title# | Description and type Type: ReactNode | Default value |
Prop titleProps# | Description and type Type: Omit<EuiTitleProps, "children"> & HTMLAttributes<HTMLHeadingElement> & { component?: ElementType; } | Default value |
Prop cancelButtonText# | Description and type Type: ReactNode | Default value |
Prop confirmButtonText# | Description and type Type: ReactNode | Default value |
Prop onConfirm# | Description and type Type: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | Default value |
Prop confirmButtonDisabled# | Description and type Type: boolean | Default value |
Prop className# | Description and type Type: string | Default value |
Prop defaultFocusedButton# | Description and type Allows focusing either the confirm or cancel button on modal initialization. "cancel" | "confirm" | Default value |
Prop buttonColor# | Description and type Type: "text" | "accent" | "primary" | "success" | "warning" | "danger" | Default value primary |
Prop maxWidth# | Description and type Sets the max-width of the modal. string | number | boolean | Default value |
Prop isLoading# | Description and type Passes boolean | Default value |
Prop role# | Description and type Identifies a modal dialog to screen readers. Modal dialogs that confirm destructive actions "dialog" | "alertdialog" | Default value |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
Prop initialFocus# | Description and type Specifies what element should initially have focus. string | HTMLElement | (() => HTMLElement) | Default value |