A contextual message block for a section of the interface. This is a custom component with no Base UI primitive. Devie adds the Callout.Icon and Callout.Content subcomponents, a variant prop on Callout.Root, and a title prop on Callout.Content.
Here is the component implementation code that you can copy to your project:
// https://devie-ui.com/components/callout
import clsx from "clsx";
import type React from "react";
import styles from "./Callout.module.scss";
type CalloutVariant = "success" | "danger" | "warning" | "primary" | "neutral";
function Root({
variant = "neutral",
children,
className,
...props
}: Callout.Root.Props) {
return (
<div
className={clsx(
styles.container,
variant === "success" && styles.variantSuccess,
variant === "danger" && styles.variantDanger,
variant === "warning" && styles.variantWarning,
variant === "primary" && styles.variantPrimary,
variant === "neutral" && styles.variantNeutral,
className,
)}
{...props}
>
{children}
</div>
);
}
function Icon({ className, ...props }: Callout.Icon.Props) {
return <div className={clsx(styles.icon, className)} {...props} />;
}
function Content({
title,
children,
className,
...props
}: Callout.Content.Props) {
return (
<div className={clsx(styles.content, className)} {...props}>
{title && <div className={styles.title}>{title}</div>}
<div className={styles.text}>{children}</div>
</div>
);
}
const Callout = {
Root,
Icon,
Content,
};
namespace Callout {
export type Variant = CalloutVariant;
export namespace Root {
export interface Props extends React.ComponentProps<"div"> {
variant?: Variant;
children: React.ReactNode;
}
}
export namespace Icon {
export interface Props extends React.ComponentProps<"div"> {
children: React.ReactElement;
}
}
export namespace Content {
export interface Props extends Omit<React.ComponentProps<"div">, "title"> {
title?: React.ReactNode;
children: React.ReactNode;
}
}
}
export default Callout;Pass title to Callout.Content to show a heading above the text. Callout.Icon is optional.
Set variant on Callout.Root to success, danger, warning, primary, or neutral. The default is neutral.