Warning Callout
A warning callout is a component used to draw attention to important alerts or potential issues that require user attention or caution. It highlights warnings, errors, or critical information that could affect the user's experience or actions, and may include additional text or links to help users understand the issue or take corrective actions.
Status: stable — exercised in composed page flows under e2e and axe, beyond the per-component checks.
This headless component renders an <aside> element with role="alert", which causes screen readers to announce the content immediately when it appears. The consumer provides the warning content as children and is responsible for all visual styling.
Example
Show demo markup
<aside class="warning-callout" role="alert" aria-label="Important"><h3>Important</h3><p>Call 111 if you cannot return to school.</p></aside>
Usage example
<script lang="ts">
import WarningCallout from "./WarningCallout.svelte";
</script>
<WarningCallout label="Session warning">
<p>Your session is about to expire.</p>
</WarningCallout>
Show Svelte source
// In your Svelte component:
import WarningCallout from "lily-design-system-svelte-headless/components/WarningCallout/WarningCallout.svelte";
<WarningCallout>
<!-- content -->
</WarningCallout>
Usage
<WarningCallout heading="Important">
<p>
If you have a peanut allergy, do not take this medicine. Talk to your doctor about alternative
treatments.
</p>
</WarningCallout>
<WarningCallout heading="School, nursery or playgroup">
<p>
Tell your child's school or nursery if they have been diagnosed with chickenpox. Stay away from
school until all the blisters have crusted over, usually 5 days after the spots first appeared.
</p>
</WarningCallout>
Props
label: string (optional) -- accessible name applied via aria-label; useful when multiple alerts exist on the same page
children: slot (required) -- the warning content to display
Keyboard Interactions
None -- this component is a passive container for alert content.
ARIA
role="alert" -- identifies the content as an alert; screen readers announce it immediately when it appears or changes
aria-label={label} -- optional accessible name to distinguish this alert from others on the page
When to Use
- Use for information that is time-critical and users must not miss
- Use for content that could significantly impact someone's health if overlooked
- Use to address common misconceptions or mistakes that could lead to harm
- Use on content pages where the warning stands out from surrounding body text
When Not to Use
- Do not use on transactional pages — the pattern is untested in that context
- Do not use when directing users to contact their GP or seek medical help — use CareCard instead
- Do not use for information that is not sufficiently important — use InsetText for general callouts
- Do not use for system-level alerts or error states — use Alert or Banner instead
- Do not use more than two on a page, or let one run past about five lines on a mobile screen: past those limits the warnings stop standing out and none is read
- Do not place one directly against a button or action link — see the spacing rules in Advice
Headless
This headless component provides an <aside> element with role="alert" (which implicitly sets aria-live="assertive") for immediate screen reader announcements. The consumer provides all warning content as children and all visual styling including borders, background colors, and icons.
Styles
The consumer provides all CSS styling. The component renders with a .warning-callout class for targeting. No default styles are included — this is a fully headless component.
Testing
- Verify the component renders an
<aside> element with class warning-callout
- Verify role="alert"` -- identifies the content as an alert; screen readers announce it immediately when it appears or changes
- Verify aria-label={label}` -- optional accessible name to distinguish this alert from others on the page
- Verify pass-through attributes are applied
Advice
- Designers: Use a distinct visual treatment (e.g., amber/yellow background, warning icon) to differentiate warnings from errors and informational messages. Ensure sufficient color contrast.
- Developers: Content within
role="alert" is announced immediately by screen readers when it appears or changes. Avoid dynamically adding and removing WarningCallout rapidly, as each change triggers an announcement.
- Limits: At most two callouts per page, and at most five lines of text on mobile. Separate a callout from a button or action link below it with a short paragraph, and give any text that follows a callout its own heading so the callout is not read as that section's opening. Use the default callout for time-critical or health-affecting information and the "important" variant (the consumer's
data-* or class hook) for everything else. Never use it in transactional pages.
- Hidden prefix: The consumer puts a visually hidden prefix such as "Important" at the start of the content so a screen reader user hears the kind of message before its text. Lily ships no English and no prop for it: supply the string in your own language, inside
ScreenReaderSpan. Omit the prefix when the callout's heading already says so. The optional label prop is separate: it is only the aria-label on the <aside>, useful to tell several callouts apart, and does not replace the hidden prefix.
Implementation Notes
- Renders an
<aside> element with role="alert" for immediate screen reader announcements
- The
role="alert" implicitly sets aria-live="assertive", meaning content is announced immediately
- The
label prop is optional since the alert content itself provides the message
- Accepts
...restProps for forwarding additional attributes to the aside element
Related components
alert — a status message for important information or feedback
information-callout — a callout box highlighting informational content
banner — a prominent message bar across the top of a page
Known limitations
None known.
References
Lily™ and Lily Design System™ are trademarks.
Canonical contract
Generated from this component's canonical metadata — the machine-checked source the implementations are held to.
Metadata
- Component: warning-callout
- PascalCase: WarningCallout
- Description: a callout box highlighting a warning message
- Purpose: Warns about a risk or a problem the reader must not miss.
- Status: stable — exercised in composed page flows under e2e and axe, beyond the per-component checks
- HTML tag: <aside>
- CSS class: .warning-callout
- Interactive: no
ARIA
role="alert" -- identifies the content as an alert; screen readers announce it immediately when it appears or changes aria-label={label} -- optional accessible name to distinguish this alert from others on the page
Keyboard
- No keyboard interactions — this is a passive element
Props
label: string (optional) -- accessible name applied via aria-label; useful when multiple alerts exist on the same page children: slot (required) -- the warning content to display