Notice
Displays a notice section with optional title and rich text content. Supports different notice types with appropriate styling and accessibility attributes.
Props
The component accepts all fields from the Notice type directly, plus:
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
title | string | No | - | Notice title |
copy | { type, uid, _version, attrs, children } | No | - | Rich text content |
type | "notice" | "quick-tip" | "warning" | "error" | No | "notice" | Notice variant type |
$ | { title?, copy?, type? } | No | - | CSLP mapping for editable fields |
className | string | No | '' | Additional CSS classes |
Notice Type Structure
interface Notice {
_version?: number;
title?: string;
copy?: {
type: string;
uid: string;
_version: number;
attrs: Record<string, any>;
children: JSONRTENode[];
};
type?: ("notice" | "quick-tip" | "warning" | "error") | null;
$?: {
title?: CSLPFieldMapping;
copy?: CSLPFieldMapping;
type?: CSLPFieldMapping;
};
}Notice Variants
The component supports four notice types, each with distinct styling:
notice(default): Informational notice with blue stylingquick-tip: Helpful tip with green stylingwarning: Warning message with teal stylingerror: Error message with red styling
Usage
Basic Usage
import Notice from '@/components/molecules/Notice';
<Notice
title="Important Information"
copy={{
type: "doc",
uid: "notice-1",
_version: 1,
attrs: {},
children: [
{
type: "p",
children: [{ text: "This is an important notice." }]
}
]
}}
type="notice"
/>With Different Types
// Quick tip
<Notice
type="quick-tip"
title="Pro Tip"
copy={/* rich text */}
/>
// Warning
<Notice
type="warning"
title="Warning"
copy={/* rich text */}
/>
// Error
<Notice
type="error"
title="Error"
copy={/* rich text */}
/>In Blog Additional Items
{item.notice && (
<Notice
{...item.notice}
className="mb-8"
/>
)}In Page Components
The Notice component can also be used in page components through the ComponentsRenderer:
// Automatically rendered when notice is included in page.componentsFeatures
- Semantic HTML: Uses
<section>with appropriate ARIA attributes - Accessibility:
- Uses
role="alert"for semantic meaning - Sets
aria-liveto "assertive" for errors/warnings and "polite" for notices/tips
- Uses
- Design System: Uses design system color tokens for consistent styling
- Type-based Styling: Each notice type has distinct visual styling
- CSLP support: Supports Contentstack Live Preview editing
- Rich Text: Supports rich text content via
RichTextRenderer - Optional Title: Title is optional and uses the
Titlecomponent
Styling
Each notice type uses specific design tokens:
- Notice: Blue accent colors (
--Color-Extended-Blue-Blue-Accent) - Quick Tip: Green accent colors (
--Color-Extended-Green-Green-Accent) - Warning: Teal accent colors (
--Color-Extended-Teal-Teal-Accent) - Error: Red colors (
--Surfaces-Extended-Red-Medium)
All notices feature:
- Left border accent (4px)
- Rounded right corners
- Background color matching the notice type
- Text color matching the notice type
Notes
- Returns
nullif both title and copy are missing - Defaults to
type: "notice"if no type is specified - Title is rendered using the
Titlecomponent withh3heading - Copy is rendered using
RichTextRendererwithcs-m-bodystyling - CSLP attributes are applied to individual fields (title, copy) via
$?.titleand$?.copy - When used in
ComponentsRenderer, wrapper CSLP is handled automatically by the renderer - Component accepts Notice fields directly (spread pattern) for compatibility with
ComponentsRenderer