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, Link, Text } from "@optiaxiom/react";
export function App() {
return (
<Banner>
<Text>
You do not have the required permissions to perform this action.
</Text>
<Text>
<Link href="data:,">Request access</Link>
</Text>
</Banner>
);
}
#
Appearance
#
Use the intent
prop to select between the different banner types.
import type { ComponentPropsWithoutRef } from "react";
import { Banner } from "@optiaxiom/react";
export function App({
intent,
}: Pick<ComponentPropsWithoutRef<typeof Banner>, "intent">) {
return <Banner intent={intent}>Description of the banner message</Banner>;
}
#
Dismissible
#
Use the onDismiss
prop to show a close button to the top right of the banner.
import { Banner, Button } from "@optiaxiom/react";
import { useState } from "react";
export function App() {
const [open, setOpen] = useState(true);
return (
<>
{open && (
<Banner onDismiss={() => setOpen(false)}>
You do not have the required permissions to perform this action.
</Banner>
)}
{!open && <Button onClick={() => setOpen(true)}>Show banner</Button>}
</>
);
}
#
Action
#
Display with customizable interactive actions.
import { Banner, Button, Flex, Link, toaster } from "@optiaxiom/react";
export function App() {
return (
<Banner onDismiss={() => {}} w="full">
<Flex flexDirection={["column", "row"]} justifyContent="space-between">
You do not have the required permissions to perform this action.
<Flex flexDirection="row">
<Link external href="data:,">
Learn more
</Link>
<Button onClick={() => toaster.create("Triggered action")} size="sm">
Action
</Button>
</Flex>
</Flex>
</Banner>
);
}
#
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.
|
className
|
intent Control the appearance by selecting between the different banner types.
Default: |
onDismiss Show a close button inside the banner and invoke this callback when the close button is clicked.
|
#
Changelog
#
#
0.12.0
#
- Breaking: renamed
onClose
prop toonDismiss
#
0.1.0
#
- Added component