Back to Onyx

MessageCard

web/lib/opal/src/components/cards/message-card/README.md

3.3.11.8 KB
Original Source

MessageCard

Import: import { MessageCard } from "@opal/components";

A styled card for displaying messages, alerts, or status notifications. Uses Content internally for consistent title/description/icon layout. Supports 5 variants with corresponding background and border colors.

Props

PropTypeDefaultDescription
variant"default" | "info" | "success" | "warning" | "error""default"Visual variant (controls background, border, and icon)
iconIconFunctionComponentper variantOverride the default variant icon
titlestring | RichStrMain title text
descriptionstring | RichStrDescription below the title
padding"sm" | "xs""sm"Padding preset for the outer card
headerPaddingPaddingVariants"fit"Padding around the header Content area. "fit" → no padding; "sm"p-2.
bottomChildrenReactNodeContent below a divider, under the main content
rightChildrenReactNodeContent on the right side. Mutually exclusive with onClose.
onClose() => voidClose button callback. When omitted, no close button is rendered.

Usage

tsx
import { MessageCard } from "@opal/components";

// Simple info message
<MessageCard
  variant="info"
  title="Heads up"
  description="Changes apply to newly indexed documents only."
/>

// Warning with bottom content
<MessageCard
  variant="warning"
  title="Re-indexing required"
  description="Toggle this setting to re-index all documents."
  bottomChildren={<Button>Re-index Now</Button>}
/>

// Error state
<MessageCard
  variant="error"
  title="Connection failed"
  description="Unable to reach the embedding model server."
/>