alert
Open a alert modal to inspect its surface, action color, and focus behavior.
variant="alert" type="default"
WelkUI!REACT EDITIONExplore live variants, compare states, and learn every prop. Pick a component to start.
A controlled native modal dialog with a comic surface and focus containment. The parent owns open and must close it in onClose. Escape requests dismissal; optional backdrop dismissal is off by default. Action callbacks let the application perform work before updating visibility.
import { useState } from "react";
import { WelkButton, WelkDialog } from "@welkui/react";
const [open, setOpen] = useState(false);
<WelkButton onClick={() => setOpen(true)}>Open dialog</WelkButton>
<WelkDialog open={open} onClose={() => setOpen(false)}
title="Ready for adventure?" type="confirmation">
Choose your next chapter.
</WelkDialog>Import @welkui/react/styles.css once in your app. Stateful snippets belong inside a React component.
These are real components, not screenshots. Compare their appearance and try the controls. Key props below each preview show what changes; use the usage example above for imports and component setup.
Open a alert modal to inspect its surface, action color, and focus behavior.
variant="alert" type="default"Open a info modal to inspect its surface, action color, and focus behavior.
variant="info" type="default"Open a warning modal to inspect its surface, action color, and focus behavior.
variant="warning" type="default"Open a error modal to inspect its surface, action color, and focus behavior.
variant="error" type="default"Open a success modal to inspect its surface, action color, and focus behavior.
variant="success" type="default"Two actions with independent callbacks. The result is displayed after the modal closes.
type="confirmation" onYesPress={...} onNoPress={...}Required props are marked in the default column. Other props are optional. ReactNode accepts text or JSX.
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | Required | Controlled visibility. Set false when dismissal is requested. |
onClose | () => void | Required | Dismissal callback; the parent must update open. |
title | ReactNode | Required | Visible title and accessible dialog name. |
children | ReactNode | Unset | Panel content. |
closeOnTapOutside | boolean | false | Allows dismissal by pressing and releasing on the backdrop. |
className | string | Unset | Additional CSS class on the component root. |
variant | "alert" | "info" | "warning" | "error" | "success" | "alert" | Dialog color treatment. |
type | "default" | "confirmation" | "default" | Single-action or two-action footer. |
closeLabel | string | "Close dialog" | Accessible name for the close button. |
buttonText | string | "Okay" | Default-mode action label. |
onPress | MouseEventHandler<HTMLButtonElement> | Closes dialog | Default-mode action callback. When supplied, it replaces automatic action-button dismissal. |
yesText | string | "Yes" | Confirmation positive-action label. |
noText | string | "No" | Confirmation negative-action label. |
onYesPress | MouseEventHandler<HTMLButtonElement> | Closes dialog | Confirmation positive-action callback. When supplied, manage dismissal yourself. |
onNoPress | MouseEventHandler<HTMLButtonElement> | Closes dialog | Confirmation negative-action callback. When supplied, manage dismissal yourself. |
This component supports the props listed above, not arbitrary native HTML attributes.
Import @welkui/react/styles.css once in your app entry or Next.js root layout. The previews use the default theme; override --welk-* CSS tokens in your app to customize it.
For Next.js, put hooks and event handlers in a component beginning with "use client". Keep state local to the component using the control. The library preserves its client boundaries and uses your installed React version.
Use defaultValue or defaultChecked for uncontrolled fields, or a state value and its change callback for controlled fields. Do not switch between these modes during the lifetime of a field.
Modal and notification examples start closed: use their Try buttons to see them. Disabled examples are deliberately non-interactive. Validate forms, uploads, authentication, and server responses in your application; these components only provide UI.