Getting Started
Components
- Accordion
- Advanced Toast
- AlertMessage
- ArrowButton
- Arrows
- Avatar
- Backdrop
- Basic Toast
- Breadcrumb
- Button
- CardBackground
- Card
- Carousel
- Chapters
- ChatBody
- ChatButton
- ChatHeader
- ChatInput
- ChatMessageActions
- ChatMessageEditor
- ChatMessage
- ChatTypingIndicator
- ChatWindowCsatPrompt
- ChatWindowQuote
- ChatWindow
- CheckboxSelect
- Checkbox
- Checkboxes
- Chip
- ChoiceExpander
- Clickable
- ContentReview
- Countdown
- CriteriaDates
- CriteriaParticipants
- CriteriaTransports
- Date Field
- Datepicker
- Dropdown
- ElasticHeight
- ExpandableCard
- ExpandableText
- Filter
- FloatingLabelTextField
- Form Control
- Form Label
- Frame
- HamburgerIcon
- Heading
- Image
- JourneyCard
- LayerHeader
- Layer
- Link
- Loader
- Number Field
- PageNavigation
- Pagination
- Paragraph
- Password
- Phone Field
- Popin
- Portal
- ProductThumbnail
- Promises
- Prose
- Radio Group
- RadioSelect
- Radio
- Range
- Scrollbar
- Select
- SidebarLayout
- SliderFrame
- SparkleWrapper
- Spinner
- Switch
- Table
- Tabs
- Tag
- TextField
- Toggle
- Tooltip
- ValidationMessage
Alert message
Positive message
Information message
'use client';
import { IconsFixture } from '@clubmed/trident-icons/tests/IconsFixture';
import { AlertMessage } from '@/ui/AlertMessage';
export function AlertMessageDemo() {
return (
<IconsFixture>
<div className="flex flex-col items-start gap-16">
<AlertMessage status="warning" icon="Error">
Alert message
</AlertMessage>
<AlertMessage status="success" icon="CheckDefault">
Positive message
</AlertMessage>
<AlertMessage status="neutral" icon="Information">
Information message
</AlertMessage>
</div>
</IconsFixture>
);
}
Installation
npx shadcn@latest add https://develop.trident-ui.pro.clubmed/r/alert-message.json
Usage
import { AlertMessage } from '@/ui/AlertMessage';
export function Component() {
return (
<AlertMessage status="warning" icon="Error">
This field is required
</AlertMessage>
);
}Examples
Statuses
Each status applies a matching color to the text, the icon and (when bordered) the border:
| Status | Color | Suggested icon | Typical use |
|---|---|---|---|
warning | red | Error | Validation errors, blocking issues |
success | green | CheckDefault | Confirmation that an action succeeded |
neutral | black | Information | Helper text, non-critical information |
Alert message
Positive message
Information message
'use client';
import { IconsFixture } from '@clubmed/trident-icons/tests/IconsFixture';
import { AlertMessage } from '@/ui/AlertMessage';
export function AlertMessageDemo() {
return (
<IconsFixture>
<div className="flex flex-col items-start gap-16">
<AlertMessage status="warning" icon="Error">
Alert message
</AlertMessage>
<AlertMessage status="success" icon="CheckDefault">
Positive message
</AlertMessage>
<AlertMessage status="neutral" icon="Information">
Information message
</AlertMessage>
</div>
</IconsFixture>
);
}
Sizes
small (default) uses the B4 text style (14px) with a 20px icon. large uses the B3 text style (16px) with a 24px icon.
Small positive message
Large positive message
'use client';
import { IconsFixture } from '@clubmed/trident-icons/tests/IconsFixture';
import { AlertMessage } from '@/ui/AlertMessage';
export function AlertMessageSizesDemo() {
return (
<IconsFixture>
<div className="flex flex-col items-start gap-16">
<AlertMessage status="success" size="small" icon="CheckDefault">
Small positive message
</AlertMessage>
<AlertMessage status="success" size="large" icon="CheckDefault">
Large positive message
</AlertMessage>
</div>
</IconsFixture>
);
}
<AlertMessage status="success" size="large" icon="CheckDefault">
Large positive message
</AlertMessage>Bordered
Set bordered to wrap the message in a 16px-radius border in the status color. Spacing adapts to the icon: 12px all around without an icon, and 20px on the side opposite the icon when there is one.
Alert message
Positive message
Information message
'use client';
import { IconsFixture } from '@clubmed/trident-icons/tests/IconsFixture';
import { AlertMessage } from '@/ui/AlertMessage';
export function AlertMessageBorderedDemo() {
return (
<IconsFixture>
<div className="flex flex-col items-start gap-16">
<AlertMessage status="warning" bordered>
Alert message
</AlertMessage>
<AlertMessage status="success" bordered icon="CheckDefault">
Positive message
</AlertMessage>
<AlertMessage status="neutral" size="large" bordered icon="Information">
Information message
</AlertMessage>
</div>
</IconsFixture>
);
}
<AlertMessage status="neutral" size="large" bordered icon="Information">
Information message
</AlertMessage>Icon position
The icon is rendered before the label by default. Use iconPosition="right" to render it after.
Icon on the left (default)
Icon on the right
'use client';
import { IconsFixture } from '@clubmed/trident-icons/tests/IconsFixture';
import { AlertMessage } from '@/ui/AlertMessage';
export function AlertMessageIconPositionDemo() {
return (
<IconsFixture>
<div className="flex flex-col items-start gap-16">
<AlertMessage status="warning" icon="Error" iconPosition="left">
Icon on the left (default)
</AlertMessage>
<AlertMessage status="warning" icon="Error" iconPosition="right">
Icon on the right
</AlertMessage>
</div>
</IconsFixture>
);
}
<AlertMessage status="warning" icon="Error" iconPosition="right">
Icon on the right
</AlertMessage>API Reference
AlertMessage
| Prop | Type | Default | Description |
|---|---|---|---|
status | "warning" | "success" | "neutral" | "neutral" | Drives the text, icon and border color (red, green, black). |
size | "small" | "large" | "small" | small: 14px text / 20px icon. large: 16px text / 24px icon. |
bordered | boolean | false | Wraps the message in a rounded border matching the status color. |
icon | IconicNames | undefined | Optional icon from the Trident Icons library. No icon is rendered when omitted. |
iconPosition | "left" | "right" | "left" | Side of the label where the icon is rendered. |
role | AriaRole | see below | Defaults to "alert" for warning and "status" otherwise. Can be overridden. |
className | string | undefined | Extra classes for the container, merged with tailwind-merge so they can override built-in ones. |
children | ReactNode | undefined | The message content. |
All other div attributes (id, aria-*, data-*, event handlers…) are forwarded to the container.
Accessibility
warningmessages render withrole="alert"so assistive technologies announce them immediately. Render them conditionally (when the error happens) rather than toggling their visibility, otherwise the announcement may not fire.successandneutralmessages render withrole="status", which is announced politely without interrupting the user.- The icon is decorative (
aria-hidden); the label must carry the full meaning on its own. Color is never the only indicator. - When the message describes a form field, link them with
aria-describedbyon the field pointing to the messageid.
<input id="email" aria-describedby="email-error" aria-invalid="true" />
<AlertMessage id="email-error" status="warning" icon="Error">
Please enter a valid email address
</AlertMessage>Notes
- The component renders as
inline-flex, so it only takes the width of its content. AddclassName="flex"(orw-full) to make it stretch. - The icon is not chosen automatically from the status: pass
iconexplicitly. The suggested pairings are listed in the Statuses table. - Icons require an
IconsProvider(orIconsFixturein demos/tests) higher in the tree, like every other component using@clubmed/trident-icons.