@volvo-cars/react-messages
v0.5.0
Published
Volvo Car messages components
Keywords
Readme
@volvo-cars/react-messages
React components and hooks for displaying transient toast notifications and persistent inline messages, styled with @volvo-cars/css.
What's included
Toast notifications
ToastMessage— Renders a single toast notification (success, error, warning, info variants)ToastsRenderer— Renders the full list of active toasts managed by aToastManagerToastManager— Imperative manager for creating, queuing, and dismissing toasts programmaticallyuseToast— Hook for triggering toast notifications from within a React componentwithViewTransitions— Higher-order helper that enables smooth View Transition animations when toasts enter and exit
Inline messages
InlineMessage— A contextual feedback message displayed inline within a page or form (success, error, warning, info variants). PassonCloseto make it dismissible.
Installation
yarn add @volvo-cars/react-messages @volvo-cars/react-locale-providerExample
const { toast } = useToast();
<button onClick={() => toast({ type: 'success', message: 'Saved!' })}>
Save
</button>
<ToastsRenderer />