Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Feedback and display

Notice

An inline message about part of the page: a status, a warning or an error that stays in place until it is resolved or the person dismisses it.

Roles by tone

When to useLink to "When to use"

  • A lasting condition of the page or a section: sync paused, read-only mode, a quota close to its limit.
  • An error that is not about one field, such as a failed import.

Use something else when:

  • the message is a passing confirmation: a Toast
  • the error belongs to one field: that field's error text
  • the person must answer before going on: Dialog

UsageLink to "Usage"

tsx
Copy
import { Button, Notice } from "@arshad-shah/cynosure";

<Notice tone="warning" title="Storage almost full" action={<Button size="sm">Manage</Button>} dismissible>
  You have used 95% of your space.
</Notice>

Without onDismiss, the close button hides the Notice by itself. With onDismiss, you decide: remove it from your state to hide it.

Solid and smallLink to "Solid and small"

variant="solid" paints the tone's solid colour with the text colour made for it, for a message that must stand out, such as an error banner over an editor. size="sm" tightens the padding and runs the title and message on as one line when they fit, for a status strip.

tsx
Copy
<Notice tone="danger" variant="solid" size="sm" title="Query failed">
  relation "users" does not exist
</Notice>

Narrow containersLink to "Narrow containers"

The Notice measures its own width. Below 26rem the actions move under the text, so it fits side panels and extension popups.

Action drops under the text when narrow

PropsLink to "Props"

Every prop of Notice
PropWhat it doesTypeDefault
tone
Colour and icon. danger is role="alert" (announced even when it mounts filled); the others are role="status", whose content changes are announced politely.Tone
variant
soft is a tinted panel with a tone edge; solid is the tone's solid colour with the readable text that goes on it, for a message that must stand out (an editor's error banner). Default "soft"."soft" | "solid""soft"
size
sm: less padding, and the title and message share one line when they fit (a status strip). Default "md"."sm" | "md""md"
title
Short heading above the message.ReactNode
action
One or two Buttons; they move under the text in narrow containers.ReactNode
dismissible
Shows a close button. The Notice hides itself unless you control it with onDismiss and unmount it.boolean
onDismiss
Called when the close button is pressed. With it, hiding the Notice is up to you.(() => void)
icon
Replace the tone's icon, or null for none.IconData | null
labels
Replace the built-in English text: the dismiss button's name.Partial<NoticeLabels>
className
Added to the root element, for layout.string
style
Layout only. Restyle through --cy-notice-* tokens.CSSProperties
children
The message.ReactNode

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

Behaviour and accessibilityLink to "Behaviour and accessibility"

Behaviour and accessibility, table 1
InputResult
Close buttonHides it (or calls onDismiss)
  • Role: role="alert" for tone="danger", which screen readers announce even when it appears already filled. Every other tone is role="status": changes to its content are announced politely, but a status Notice that mounts with its text already in it is usually only read in place.
  • To announce a non-danger message that appears later, keep the Notice mounted and change its content, or use a Toast, which is built to be announced once.
  • Icon: decorative; the tone is also carried by the words.
  • Contrast: title and body are at least 4.5:1 in every tone and both variants, in light and dark modes. On a fill the tone icon and the close icon are at least 3:1.

TouchLink to "Touch"

The close button keeps a 44px hit area on coarse pointers.

ThemingLink to "Theming"

Tokens: --cy-notice-radius, --cy-notice-padding, --cy-notice-padding-sm (the padding of size="sm") and --cy-notice-soft-mix (how strongly the tone tints the background).

ts
Copy
createTheme({ components: { notice: { radius: "8px", softMix: "14%" } } });

Toast · Badge · EmptyState

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog