<c-alert>
A persistent, in-flow status message: a tinted box whose type carries a status family's colours through the icon, heading and accent edge, while the body copy stays neutral.
Usage
Give the alert a heading with the prop for plain text; the heading slot overrides the prop when rich content (links, emphasis) is needed. The message goes in the default slot.
When to use
- Persistent status that belongs to the page or a section: a maintenance notice, a failed validation summary, a quota warning.
- Not for transient feedback on an action — use
c-toasts, which overlays and closes itself; the alert stays in the layout until the consumer removes it.
Types
The four status types (error, info, success, warning) carry their status family's colours and icon; omitting type renders the neutral, brand-primary look, without an icon. Severity is signalled by the icon, the heading's ink and the accent edge, never by colouring the body text.
Closing
closeable renders a close button, but pressing it only fires the close event — removing the alert from the page stays the consumer's job.
Accessibility
The alert manages its own live-region role: warning and error interrupt (role="alert"), while the other types announce politely (role="status"). Content that is present at page load is not announced — live regions only announce changes.
Customization
Structural styling via ::part(root), ::part(icon), ::part(content), ::part(heading) and ::part(close). Colours come from the status-family semantic tokens; override the tokens to re-theme.
Examples
<template>
<div>
<c-alert heading="Maintenance break" type="warning">
The service will be unavailable on Saturday between 10:00 and 12:00.
</c-alert>
</div>
</template>
<template>
<div style="display: grid; gap: 1rem">
<c-alert>A default alert without a type.</c-alert>
<c-alert type="info">Your session expires in 15 minutes.</c-alert>
<c-alert type="success">Your project was created.</c-alert>
<c-alert type="warning">Your quota is almost full.</c-alert>
<c-alert type="error">The file could not be uploaded.</c-alert>
</div>
</template>
API reference
<c-alert>
A persistent, in-flow status message: a tinted box whose type carries a status family's colours through the icon, heading and accent edge, while the body copy stays neutral.
Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
closeable | closeable | boolean | false | Show a close button. The alert only fires `close` — removing it from the page stays the consumer's job. |
heading | heading | string | — | Heading rendered above the message. The `heading` slot overrides it for rich content. |
type | type | CAlertType | — | The status type, setting the colours, the icon and how urgently the alert is announced (`warning` and `error` interrupt). Without it the alert has the neutral, brand-primary look and no icon. |
Events
| Event | Detail | Description |
|---|---|---|
close | void | Fired when the close button is pressed. The alert does not hide itself — the consumer owns removal. |
Slots
| Slot | Description |
|---|---|
heading | Rich heading content; overrides the `heading` prop |
default | The message |
CSS parts
Style from outside with c-alert::part(name) — parts are the library's only styling customization API.
| Part | Description |
|---|---|
root | The box carrying the type's tint, hairline border and accent edge |
icon | The status icon, rendered only when a `type` is set |
content | The wrapper around the heading and message content |
heading | The heading paragraph rendered from the `heading` prop |
close | The close button rendered when `closeable` is set |
Types
Importable from the package root: import type { … } from '@cscfi/csc-ui'
CAlertType
Type of the alert: the four status types carry their status family's colours and icon. Omitting it renders the neutral look, in the brand primary colour (unlike `c-status`, whose neutral pill is grey) and without an icon.
export type CAlertType = 'error' | 'info' | 'success' | 'warning';