Notification
Inline message card for system events, with optional icon, timestamp, actions, and dismiss control.
Notification renders a <div> card and lets the surrounding app decide on live-region semantics. The dismiss button is rendered via IconButton and labelled by dismissLabel (defaults to Dismiss notification).
import { Notification } from '@arshad-shah/cynosure-react';
export default function Example() {
return <Notification title="Saved" description="Your changes have been saved." />;
}
With icon and timestamp
Section titled “With icon and timestamp”Pass any node to icon for a leading glyph and a string or node to timestamp for an aligned trailing time.
import { Notification } from '@arshad-shah/cynosure-react';
const BellIcon = () => (
<svg
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="1.75"
strokeLinecap="round"
strokeLinejoin="round"
aria-hidden="true"
>
<path d="M18 16v-5a6 6 0 1 0-12 0v5l-2 3h16l-2-3Z" />
<path d="M10 20a2 2 0 0 0 4 0" />
</svg>
);
export default function Example() {
return (
<Notification
icon={<BellIcon />}
title="New comment"
description="Grace Hopper left a comment on your pull request."
timestamp="2m ago"
/>
);
}
Unread state
Section titled “Unread state”Pass unread to render the unread indicator dot. The optional onRead callback fires when the card is clicked so consumers can mark the notification as read.
import { Notification } from '@arshad-shah/cynosure-react';
import { useState } from 'react';
export default function Example() {
const [unread, setUnread] = useState(true);
return (
<Notification
unread={unread}
onRead={() => setUnread(false)}
title="Build finished"
description="Your deployment to staging is ready to review."
timestamp="just now"
/>
);
}
With actions
Section titled “With actions”The actions slot accepts any node — typically a row of Buttons for inline responses.
import { Button, Notification } from '@arshad-shah/cynosure-react';
export default function Example() {
return (
<Notification
title="Invitation pending"
description="Ada Lovelace invited you to the Cynosure workspace."
timestamp="5m ago"
actions={
<>
<Button size="sm">Accept</Button>
<Button size="sm" variant="ghost">
Decline
</Button>
</>
}
/>
);
}
Dismissable
Section titled “Dismissable”Set onDismiss to render the close IconButton. Use dismissLabel to override the default "Dismiss notification" label.
import { Notification } from '@arshad-shah/cynosure-react';
import { useState } from 'react';
export default function Example() {
const [open, setOpen] = useState(true);
if (!open) return null;
return (
<Notification
title="Heads up"
description="You can dismiss this notification once you've read it."
onDismiss={() => setOpen(false)}
/>
);
}
Accessibility
Section titled “Accessibility”- The card itself is not a live region — wrap a stack of notifications in
role="status"orrole="log"when announcements are needed. - The dismiss control is an
IconButtonwhose label isdismissLabel— defaults to"Dismiss notification". - The unread dot is decorative (
aria-hidden="true"); pair it with a visible label such as “Unread” when state matters. - Clicking the card triggers
onReadwhenunreadis set, so non-pointer users should also be able to mark items read via an explicit control. - Use a heading element inside
title(or nest your own heading) when the notification sits at the top of a region.
Recipes
Section titled “Recipes”- Stack notifications inside a fixed-position container to build a notification centre.
- Auto-dismiss informational notifications after a few seconds; keep dangerous ones manual.
- Pair a primary action with a “Mark as read” secondary button inside
actions. - Use a leading
Avataras theiconfor activity feeds.