Skip to documentation

Design system / Molecules

Molecule / Feedback

Alert

Alert presents feedback through a container, title and description. The caller supplies the message, rendering condition and recovery action. The default alert role can be overridden for static explanatory content.

Live example

Live preview

Current component with fictional data. Example changes are not persisted.

Sample information
The consumer supplies feedback and timing.
Example error
No product operation was attempted.

Responsibility

The assembled title, description and optional icon present one feedback message. The caller chooses announcement semantics and recovery behavior. A linked validation summary requires a separate composition.

Public contract

The table describes supported inputs, exported parts and caller responsibilities. A callback supplies a command, such as saving a draft. These notes are maintained manually; check current source types before integration.

Maintained component API notes; current source is authoritative
Prop / partTypeRequirementResponsibility
variantdefault | destructiveOptional · default defaultContainer appearance; not a severity inference or workflow state.
className / native propsReact.ComponentProps<"div">OptionalAccepted by each part. The container starts with role="alert"; spread props can override it.
childrenReactNodeConsumer assemblyCompose title, description and optional direct-child SVG. No named message or icon prop.

API notes are curated documentation, not generated types. The source linked above is the current implementation; update these notes alongside API changes.

State and behavior

Identify which values the caller controls and which behavior the component or underlying primitive owns. A local example does not supply persistence, authorization or a complete product lifecycle.

No internal state or request hook. The consumer decides when to render feedback and supplies the message. A destructive variant changes appearance, not data or error handling.

Dependencies

  • Alert container
  • AlertTitle and AlertDescription
  • Optional consumer-supplied SVG
  • cva and cn

Token and styling contract

These notes identify theme roles, utilities and direct style values used by the source. Direct colors or timings are implementation exceptions, not recommendations to bypass the theme.

bg-card / text-card-foreground
Default container roles.
text-destructive
Destructive message and icon treatment.
text-muted-foreground / text-md
Description and type roles; destructive description overrides muted text.
rounded-lg, border, px-4, py-3
Container geometry; grid adapts to a direct-child SVG.

Boundaries and limitations

  • No dismiss, retry, loading or success lifecycle is built in.
  • AlertTitle is a div with line-clamp-1, not a semantic heading. Avoid hiding essential feedback; override deliberately where needed.
  • role="alert" can announce dynamic messages assertively. Choose announcement policy in the consumer rather than using it for every static note.

Where to make a change

Change common feedback anatomy in alert.tsx. Change validation, timing, copy and recovery in the consumer or hook. Preserve role semantics and readable error content when changing visual variants.

Selected real uses

SubmissionForm

Shows a supplied mutation error in a destructive Alert above the shared creation/editing form. The edit instance passes useEditSubmission feedback here; field validation and attachment-description errors have their own form feedback.

src/components/submissions/submissionForm.tsx

These traces describe selected uses, not every dependency. Repository-only paths are shown as references; only approved files have public source views.

Usage contract

import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert";

<Alert variant="destructive">
  <AlertTitle>Changes were not saved</AlertTitle>
  <AlertDescription>{error}</AlertDescription>
</Alert>

Illustrative consumer bindings, not a self-contained product workflow. Live examples supply only local state or explicit fictional props.

All molecules
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.