Componentsv2.189.0
Iconsv1.19.0
MCPv0.8.61
Tokensv0.34.3

Banners prominently communicate contextual information.

Importing

The component can be imported via:

import { Banner, BannerDescription, BannerTitle } from '@customerio/pluma-components/react';

Elements of a banner

Variant

A banner's variant is tied to its semantic meaning, and determines the color and default icon used in a banner. The available variants are:

  • default
    • Used to share non-urgent information such as "pro tips"
Loading editor
  • information
    • Used to bring awareness to helpful information
Loading editor
  • success
    • Used to inform users of success or completion
Loading editor
  • caution
    • Used to caution the user
Loading editor
  • error
    • Used to inform users of dangerous actions, failures, or errors
Loading editor
  • feature
    • Used to alert customers of something new or promote a call-to-action
Loading editor

Type

A banner contains 3 different style types:

  • inline
    • Used to display a banner inline, along with the content it's related to
    • Styled with a subtle bottom border
Loading editor
  • alert
    • A floating banner that communicates information about the whole page, or when there isn't one specific element to attach it to
    • Styled with a bottom border and a shadow
Loading editor
  • announcement
    • A full-width banner appearing at the top of the app
    • Styled with no border, no border radius, and the content centered
Loading editor

Title

Use the title to efficiently communicate the core of the message. Starting a title with a short phrase ('Heads up!', 'Oh no!', 'Pro tip:', etc.) can help communicate the tone.

Loading editor

Description

The banner's body text can be provided with the description prop in React or the @description argument in Ember:

Loading editor

Rich description content, like links, may be passed into the description prop or Ember description named block:

Loading editor

Custom content

Regular React children and Ember default yielded content render directly in the banner content area. Use BannerTitle/BannerDescription or PlumaBannerTitle/PlumaBannerDescription when composing custom content that should match Banner title and description styles:

Loading editor

Icon

The banner will default to an icon that is appropriate for the chosen variant. The icon can be changed with the icon prop:

Loading editor

Be careful when choosing an icon to avoid miscommunication. For example, don't show a checkmark in a error banner.

Actions

Add a primary action to a banner when an action is possible outside of closing/dismissing the banner. The label for the action is customizable.

Example: Saving some data failed, so the user can try again from the alert.

The action prop accepts an object that represents either a link or a button. If the href key is present, the banner will render a link (styled like a button). Otherwise, a button will be rendered. The shape of the object is:

{
	label: string;
	href?: string;
	isExternal?: boolean;
	onClick?: () => void;
	isDisabled?: boolean;
	variant?: 'primary' | 'secondary' | 'tertiary' | 'subtle';
	isLoading?: boolean;
	autoLoading?: boolean;
}

or

{
	label: string;
	onClick?: () => void;
	isDisabled?: boolean;
	variant?: 'primary' | 'secondary' | 'tertiary' | 'subtle';
	isLoading?: boolean;
	autoLoading?: boolean;
}

The variant property allows you to customize the button's visual style. By default, banner action buttons use the "subtle" variant.

The isLoading property can be used to manually set the action button to a loading state, which shows a spinner and disables interactions. The autoLoading property (enabled by default) will automatically set the button to a loading state when the onClick handler returns a Promise, until that Promise resolves or rejects.

Loading editor
Loading editor
Loading editor

Dismiss button

Sometimes, you may also want to display a "dismiss" button along with the action. This can be accomplished by enabling shouldShowDismissButton and passing in an onClose callback (which will be called when the button is clicked):

Loading editor

The text of the button can be changed with the dismissButtonText prop. If this prop is present, shouldShowDismissButton is not required:

Loading editor

Close button

As an alternative to the "dismiss" button, an "X" close button can be displayed. This can be enabled by passing in an onClose callback, but without enabling shouldShowDismissButton or customizing dismissButtonText:

Loading editor

Outlined style

By default, banners have a colored background. You can use the isOutlined prop to switch to an outlined style with a white background and a colored border:

Loading editor
Loading editor

API

Action button to render in the banner.

The description of the banner, if any.

Default:'Dismiss'

The text to show in the dismiss button

The name of an icon (from Pluma Icons) to render in the banner.

Whether the close button should be disabled.

Whether the dismiss button should be disabled.

Default:false

Whether the banner should have a white background with a colored border.

Function to call when the "X" close button is clicked. Providing this prop will render the close button (unless shouldShowDismissButton is also enabled).

Whether a "dismiss" action button should be rendered inside the banner. Calls onClose when clicked, if provided.

The title of the banner, if any.

Default:inline

The type of banner to render.

Default:default

The semantic variant (color) of banner to render.

Whether the banner should be rendered with a responsive container.

This automatically stacks the content and actions when the banner is too narrow. By default, it is true when the banner type is 'inline' and we are not showing the close button.