Skip to Content
ComponentsBanner

Banner

A Banner shows an important message with optional actions. It appears below the top app bar and requires user dismissal.

GitHub LogoSource Code

Actions

You can add a set of actions to the banner by specifying the actions prop. The onAction prop is a callback function that is called when an action is clicked.

If you want to show a close button, you’ll need to pass a function to the onClose prop.

By default, the actions will be placed inline with the banner content. You can change this behavior by using the actionsPosition prop.

You can also pass custom action components, instead of the actions prop. In this case the onAction prop will not be called when an action is clicked, so you’ll need to handle the click events yourself.

Custom icons

You can pass a custom icon to the banner by using the customIcon prop.

Controlled

Controlled banner. Click the buttons to display different banners.

Showing a banner inline with content

The HvBanner component is typically used as a global banner with a fixed position and transition. But you can also use it inline with other content by using the HvBannerContent component directly. You may also want to use the banner contained on the top of a section. While the component itself doesn’t support it out of the box, you can achieve this effect by customizing the styles a bit. The example below shows illustrates both use cases.

Last updated on