Banner
Display a prominent message at the top of the screen.
#
Documentation
#
#
Usage
#
You do not have the required permissions to perform this action.
import {
Banner,
BannerDescription,
BannerTitle,
Link,
Text,
} from "@optiaxiom/react";
export function App() {
return (
<Banner>
<BannerTitle>Some action is not permitted</BannerTitle>
<BannerDescription>
<Text>
You do not have the required permissions to perform this action.
</Text>
<Text>
<Link href="data:,">Request access</Link>
</Text>
</BannerDescription>
</Banner>
);
}
#
Appearance
#
Use the intent
prop to select between the different banner types.
import type { ComponentPropsWithoutRef } from "react";
import { Banner, BannerDescription, BannerTitle } from "@optiaxiom/react";
export function App({
intent,
}: Pick<ComponentPropsWithoutRef<typeof Banner>, "intent">) {
return (
<Banner intent={intent}>
<BannerTitle>Banner title</BannerTitle>
<BannerDescription>Description of the banner message</BannerDescription>
</Banner>
);
}
#
Close button
#
Use the onClose
prop to show a close button to the top right of the banner.
import {
Banner,
BannerDescription,
BannerTitle,
Button,
} from "@optiaxiom/react";
import { useState } from "react";
export function App() {
const [open, setOpen] = useState(true);
return (
<>
{open && (
<Banner onClose={() => setOpen(false)}>
<BannerTitle>Some action is not permitted</BannerTitle>
<BannerDescription>
You do not have the required permissions to perform this action.
</BannerDescription>
</Banner>
)}
{!open && <Button onClick={() => setOpen(true)}>Show banner</Button>}
</>
);
}
#
Related
#
Alert
Show inline messages about important or time-sensitive changes.
Toast
Display brief popup notifications.
#
Props
#
#
Banner
#
Supports all Box props in addition to its own. Renders a <div>
element.
Prop |
---|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details. false | true |
className string |
intent Control the appearance by selecting between the different banner types. "information" | "success" | "warning" | "danger" | "neutral" Default: neutral |
onClose Show a close button inside the banner and invoke this callback when the close button is clicked. () => void |
#
BannerTitle
#
Supports all Box props in addition to its own. Renders a <div>
element.
Prop |
---|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details. false | true |
className string |
#
BannerDescription
#
Supports all Box props in addition to its own. Renders a <div>
element.
Prop |
---|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details. false | true |
className string |
#
Changelog
#
#
0.1.0
#
- Added component