Fusion UI LogoFusion UI Logo
Fusion UI LogoFusion UI Logo
/
Getting Started
Concepts
Components
Example Apps
Getting Started
Concepts
Components
Example Apps
Fusion UI LogoFusion UI Logo
Getting Started
Concepts
Components
Example Apps
Overview
Actions
Button
Button Group
Segmented Button
Deprecated
Split Button
Toggle Button
Click To Copy
Toolbar
Navigation
Main Nav
Side Menu
Page Header
Tabs
Breadcrumbs
On-Page Menu
Link
Command Menu
Application Switcher
Context Switcher
Account Menu
Menu Bar
Deprecated
Inputs & Forms
Form
Form Actions
Deprecated
Form Divider
Form Field
Form Repeat
Form Spacing
Input
Prefix & Suffix
Rich Text Input
Autocomplete
Select
Date / Time Input
Calendar
Slider
Selection
Checkbox
Radio
Switch
Switch Select
Chip
Chip Choice
Chip Filter
Chip Input
Chip Sortable
Visual Select
Pricing Plan Select
Feedback & Loading
Banner
Inline Message
Snackbar
Inline Snackbar
Loading Spinner
Skeleton
Text Skeleton
Contextual Information
Badge
Status
Tag
Tooltip
Info
Hotkey
Icon
Icon Sizer
Containers & Overlays
Tile
Tile Content
Tile Footer
Tile Header
Annotated Section
Modal
Sheet
Popover
Context Menu
Data Display
Data Table
List
Timeline
Data Visualization
KPI Card
Ratio Card
Bar Chart
Line Chart
Pie Chart
Heatmap Calendar
Layout
Container
Stack Layout
Flow Layout
Internals
Blanket
Expansion Panel
Menu List Base
Menu Group
Search Bar
Components
...
Banner

Banner

Application wide message above all content, e.g. maintenance or trial end.

Overview

A Banner shows a message at the top edge of the application, above all views, in different styles and with an optional icon. useBanner() shows and hides it; the other views move down to make room.

"use client";
import {Banner, Button, IconInformation, Link, useBanner} from "@brynlabs/fusion-ui";
import React, {useState} from "react";
export const BannerExample = () => {
const {showBanner, hideBanner} = useBanner();
const [isBannerVisible, setIsBannerVisible] = useState(false);
const toggleBanner = () => {
if (isBannerVisible) {
hideBanner();
} else {
showBanner(
<Banner icon={<IconInformation />} bannerStyle="warn">
New version available! See{" "}
<Link
linkStyle={"secondary"}
link={{
href: "/components/link",
title: "Primary Link",
}}>
further documentation
</Link>
.
</Banner>,
);
}
setIsBannerVisible(!isBannerVisible);
};
return <Button onClick={toggleBanner}>{isBannerVisible ? "Hide Banner" : "Show Banner"}</Button>;
};

Styles

Banner message
warn
"use client";
import {
Banner,
BannerStyle,
Button,
IconErrorWarning,
IconAlert,
Input,
Select,
useBanner,
} from "@brynlabs/fusion-ui";
import React, {JSX, useState} from "react";
export const BannerStylesExample = () => {
const {showBanner, hideBanner} = useBanner();
const [isBannerVisible, setIsBannerVisible] = useState(false);
const [value, setValue] = useState("You found the banner!");
const [styleValue, setStyleValue] = useState<BannerStyle>("warn");
const iconMap: Record<BannerStyle, JSX.Element> = {
critical: <IconErrorWarning />,
warn: <IconAlert />,
};
const toggleBanner = (message: string, style: BannerStyle) => {
if (isBannerVisible) {
hideBanner();
} else {
showBanner(
<Banner icon={iconMap[style]} bannerStyle={styleValue}>
{value}
</Banner>,
);
}
setIsBannerVisible(!isBannerVisible);
};
return (
<div style={{display: "flex", flexDirection: "column", gap: "20px"}}>
<Input label={"Banner message"} value={value} onChange={v => setValue(v)}></Input>
<div>
<Select
placeholder={"default"}
value={styleValue}
values={["warn", "critical"]}
onChange={v => setStyleValue(v as BannerStyle)}></Select>
</div>
<div>
<Button onClick={() => toggleBanner(value, styleValue)}>
{isBannerVisible ? "Hide Banner" : `Open ${styleValue} snackbar`}
</Button>
</div>
</div>
);
};