Component Contract

Alerts

Communicate important contextual messages — success, warning, error, informational — to members of the CAAT Pension Plan.

Live Demo

Info Alert

Rendered

Success Alert

Rendered

Warning Alert

Rendered

Error / Danger Alert

Rendered

Dismissible Alert

Rendered

States

The alert variants are static (no interaction states). The only interactive element is the dismiss button on dismissible alerts, which implements default, hover, and focus. The static is-* classes mirror the live pseudo-class states.

Dismiss button

Code sample

HTML

<!-- Info alert -->
<div class="caat-alert caat-alert--info" role="alert" aria-live="polite">
  <i class="bi bi-info-circle-fill caat-alert__icon" aria-hidden="true"></i>
  <div class="caat-alert__body">
    <strong>Heading</strong>
    <p>Message body text.</p>
  </div>
</div>

<!-- Dismissible danger alert -->
<div class="caat-alert caat-alert--danger" role="alert" aria-live="assertive">
  <i class="bi bi-x-octagon-fill caat-alert__icon" aria-hidden="true"></i>
  <div class="caat-alert__body">
    <strong>Error Heading</strong>
    <p>Error description.</p>
  </div>
  <button type="button" class="caat-alert__close" aria-label="Dismiss alert">
    <i class="bi bi-x-lg" aria-hidden="true"></i>
  </button>
</div>

1. Summary

Component namecaat/components/alert
PurposeCommunicate time-sensitive or contextually important messages to CAAT Pension Plan members and employers — including system announcements, action confirmations, deadline warnings, and form validation errors.
Status New
VariantsInfo, Success, Warning, Danger (Error)
OptionsDismissible toggle, optional icon override, optional heading
AEM resource typecaat/components/alert
AEM categoryCAAT Components – Feedback

2. Design Tokens

Alerts consume the semantic --caat-color-feedback-* tokens (each aliases an alert primitive in tokens.css); the icon inherits the variant's text colour.

TokenRole
--caat-color-feedback-info-bg / -border / -textInfo variant surface, border, and text/icon
--caat-color-feedback-success-bg / -border / -textSuccess variant surface, border, and text/icon
--caat-color-feedback-warning-bg / -border / -textWarning variant surface, border, and text/icon
--caat-color-feedback-danger-bg / -border / -textDanger variant surface, border, and text/icon
--caat-color-text-linkLinks within the alert body
--caat-radiusAlert container corner radius
--caat-font-primaryFont family

3. Authoring Fields

FieldTypeRequiredNotes
Alert TypeDropdown (info | success | warning | danger)YesDetermines colour scheme, default icon, and aria-live value.
HeadingText fieldYesRendered as <strong> within the alert body. Max 80 characters.
BodyRich text (limited)YesSupports paragraphs, lists, inline links. No images or embeds.
DismissibleToggle (boolean)NoDefault: off. Adds close button and wires JS dismiss behaviour.
Icon OverrideIcon pickerNoReplaces the default icon for the selected alert type.

4. Validation Rules

  • Alert Type is mandatory; component will not render without it.
  • Heading max length: 80 characters. Exceeding triggers an author-facing warning.
  • Body is required; component must not render an empty alert container.
  • Body rich text: only <p>, <ul>, <ol>, <li>, <a>, <strong>, <em> elements permitted.
  • If Dismissible is true, the component must render the close button and include the dismiss JS.

5. Content Guidance

GuidelineDetail
ToneClear, concise, supportive. Avoid jargon. Pension-plan members range widely in financial literacy.
HeadingUse action-oriented language. State what happened or what's needed — e.g., "Contribution Deadline Approaching" rather than "Alert".
Body length1–3 sentences ideal. Use a list for multiple error items.
Use Info forSystem announcements, scheduled maintenance, new features.
Use Success forCompleted actions — enrollment confirmed, form submitted, payment received.
Use Warning forUpcoming deadlines, expiring sessions, incomplete profiles.
Use Danger forValidation errors, failed transactions, critical account issues.
Don'tStack more than 2 alerts on a page. Avoid danger alerts for non-critical issues.

6. Semantic HTML

HTL / Markup contract

<!-- Non-destructive alert (info, success, warning) -->
<div class="caat-alert caat-alert--{type}"
     role="alert"
     aria-live="polite"
     data-caat-alert>
  <i class="bi bi-{icon} caat-alert__icon" aria-hidden="true"></i>
  <div class="caat-alert__body">
    <strong>{heading}</strong>
    {bodyRichText}
  </div>
  <!-- If dismissible -->
  <button type="button" class="caat-alert__close" aria-label="Dismiss alert">
    <i class="bi bi-x-lg" aria-hidden="true"></i>
  </button>
</div>

<!-- Error/Danger alert -->
<div class="caat-alert caat-alert--danger"
     role="alert"
     aria-live="assertive"
     data-caat-alert>
  <i class="bi bi-x-octagon-fill caat-alert__icon" aria-hidden="true"></i>
  <div class="caat-alert__body">
    <strong>{heading}</strong>
    {bodyRichText}
  </div>
</div>

Key decisions

  • role="alert" ensures assistive technology announces the content.
  • aria-live="polite" for info/success/warning — doesn't interrupt current task.
  • aria-live="assertive" for danger/error — immediately announces to screen readers.
  • Icon uses aria-hidden="true" as meaning is conveyed by text and colour.
  • Close button uses aria-label="Dismiss alert" for screen-reader clarity.

7. CSS Contract

SelectorPurpose
.caat-alertBase container — flex layout, padding, border-radius, border-left accent.
.caat-alert--infoInfo colour scheme (blue background, border, icon).
.caat-alert--successSuccess colour scheme (green background, border, icon).
.caat-alert--warningWarning colour scheme (amber/yellow background, border, icon).
.caat-alert--dangerDanger colour scheme (red background, border, icon).
.caat-alert__iconIcon sizing and colour via variant token.
.caat-alert__bodyText container — flex-grow, typography settings.
.caat-alert__closeDismiss button — positioned end, transparent background, hover state.

Sample CSS

.caat-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--caat-alert-border-radius);
  border-left: 4px solid;
}

.caat-alert--info {
  background: var(--caat-alert-info-bg);
  border-color: var(--caat-alert-info-border);
}
.caat-alert--info .caat-alert__icon { color: var(--caat-alert-info-icon); }

.caat-alert--success {
  background: var(--caat-alert-success-bg);
  border-color: var(--caat-alert-success-border);
}
.caat-alert--success .caat-alert__icon { color: var(--caat-alert-success-icon); }

.caat-alert--warning {
  background: var(--caat-alert-warning-bg);
  border-color: var(--caat-alert-warning-border);
}
.caat-alert--warning .caat-alert__icon { color: var(--caat-alert-warning-icon); }

.caat-alert--danger {
  background: var(--caat-alert-danger-bg);
  border-color: var(--caat-alert-danger-border);
}
.caat-alert--danger .caat-alert__icon { color: var(--caat-alert-danger-icon); }

.caat-alert__icon {
  font-size: var(--caat-alert-icon-size);
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.caat-alert__body { flex: 1; }

.caat-alert__close {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}
.caat-alert__close:hover { opacity: 1; }

8. Accessibility

RequirementImplementation
ARIA rolerole="alert" on the container element.
Live regionaria-live="polite" for info/success/warning; aria-live="assertive" for danger.
Colour contrastText meets WCAG 2.1 AA (4.5:1). Icon colour meets 3:1 against background.
Colour not sole indicatorEach variant uses a distinct icon shape + text label alongside colour.
Dismiss focus managementOn dismiss, focus moves to the next focusable element or the element that triggered the alert. Alert container is removed from DOM.
Close buttonaria-label="Dismiss alert". Keyboard accessible via Enter / Space.
Reduced motionDismiss animation respects prefers-reduced-motion: reduce.

9. SEO

Transient / structural UI with no indexable content of its own — no SEO markup required. Ensure any content this component wraps or reveals stays server-rendered and crawlable.

10. Analytics

Analytics are captured through the shared data-analytics-component attribute on the component root (emitted automatically) and reported to the central data layer. Event names and payloads follow the organisation's standard analytics schema — defined centrally with the analytics team, not invented per component — so no bespoke tracking is specified here.

11. AEM Notes

  • Resource type: caat/components/alert
  • Component group: CAAT Components – Feedback
  • Proxy: Create as a proxy component under /apps/caat/components/alert.
  • Policies: Configure allowed alert types per template via content policies (e.g., landing pages may restrict danger alerts).
  • Sling Model: com.caat.core.models.AlertModel — exposes type, heading, body, dismissible, iconOverride.
  • HTL: alert.html — uses data-sly-attribute to set variant class and aria-live value dynamically.
  • Client library: caat.components.alert (categories: caat.site).
  • Style System: Not applicable — type selection via dedicated dropdown rather than style tab.

12. Dialog Model (YAML)

Simplified model — shows field intent and Granite UI resource types, not the literal cq:dialog node tree (e.g. select options are authored as child items nodes).

title: Alert
description: Contextual feedback message for members.
fields:
  - name: alertType
    label: Alert Type
    type: select
    required: true
    options:
      - value: info
        label: Information
      - value: success
        label: Success
      - value: warning
        label: Warning
      - value: danger
        label: Danger / Error
    helpText: Determines colour, icon, and screen-reader announcement priority.

  - name: heading
    label: Heading
    type: textfield
    required: true
    maxLength: 80
    helpText: Brief action-oriented summary (e.g., "Contribution Deadline Approaching").

  - name: body
    label: Body
    type: richtext
    required: true
    allowedElements: [p, ul, ol, li, a, strong, em]
    helpText: Supporting detail. Keep to 1–3 sentences or a short list.

  - name: dismissible
    label: Dismissible
    type: checkbox
    required: false
    defaultValue: false
    helpText: Adds a close button. Use for non-critical informational alerts only.

  - name: iconOverride
    label: Icon Override
    type: iconpicker
    required: false
    helpText: Leave empty to use the default icon for the selected alert type.

13. QA Acceptance Checklist

  • All four variants (info, success, warning, danger) render with correct colours, icons, and ARIA attributes.
  • Dismissible alert shows close button; clicking it removes the alert from the DOM and moves focus appropriately.
  • Screen reader announces alert content on page load; danger alerts use assertive live region.
  • Colour contrast meets WCAG 2.1 AA for all variants (text 4.5:1, icons 3:1).
  • Alert does not render if heading or body is empty (validation enforced in dialog).
  • Icon override replaces default icon when configured.
  • Responsive: alert stacks cleanly on mobile viewports (320 px+).
  • Dismiss animation is suppressed when prefers-reduced-motion: reduce is active.
  • Analytics events (alert-displayed, alert-dismissed) fire correctly with expected data attributes.
  • Cross-browser tested: Chrome, Firefox, Safari, Edge.

14. Definition of Done

AreaDone means
Design Figma component matches this contract. All four variants documented with light/dark tokens. Icon + text + colour used together — no reliance on colour alone.
Development AEM proxy component created. HTL template emits semantic HTML per Section 6. CSS uses design tokens exclusively. JS implements dismiss behaviour and fires analytics events. Unit tests pass.
QA All items in the QA Acceptance Checklist (Section 13) pass. Manual accessibility audit completed. Cross-browser tested (Chrome, Firefox, Safari, Edge).
Launch Component deployed to AEM production. Content authors trained on appropriate alert type selection. Documentation published. Analytics dashboards confirmed receiving events.