---
layout: ~/layouts/MdxDocLayout.astro
title: "Banner"
description: "Displays contextual inline messages for informational, alert, or error states."
sourceFile: "components/banner"
---

import ComponentExample from "~/components/docs/ComponentExample.astro";
import ComponentSection from "~/components/docs/ComponentSection.astro";
import CodeBlock from "~/components/docs/CodeBlock.astro";
import PropsTable from "~/components/docs/PropsTable.astro";
import Heading from "~/components/docs/Heading.astro";
import {
  BannerVariantsDemo,
  BannerDefaultDemo,
  BannerAlertDemo,
  BannerErrorDemo,
  BannerWithIconDemo,
  BannerWithActionDemo,
  BannerWithActionsDemo,
  BannerCustomContentDemo,
} from "~/components/demos/BannerDemo";

{/* Hero Demo */}

<ComponentSection>
  <ComponentExample demo="BannerVariantsDemo">
    <BannerVariantsDemo client:visible />
  </ComponentExample>
</ComponentSection>

{/* Installation */}

<ComponentSection>
  <Heading level={2}>Installation</Heading>
  <Heading level={3}>Barrel</Heading>
  <CodeBlock code={`import { Banner } from "@cloudflare/kumo";`} lang="tsx" />
  <Heading level={3}>Granular</Heading>
  <CodeBlock
    code={`import { Banner } from "@cloudflare/kumo/components/banner";`}
    lang="tsx"
  />
</ComponentSection>

{/* Usage */}

<ComponentSection>
  <Heading level={2}>Usage</Heading>

```tsx
import { Banner } from "@cloudflare/kumo";
import { Info } from "@phosphor-icons/react";

export default function Example() {
  return (
    <Banner
      icon={<Info weight="fill" />}
      title="Update available"
      description="A new version is ready to install."
    />
  );
}
```

</ComponentSection>

{/* Examples */}

<ComponentSection>
  <Heading level={2}>Examples</Heading>

<Heading level={3}>Variants</Heading>

<h4 class="mb-3 text-base font-medium">Default</h4>
<ComponentExample demo="BannerDefaultDemo">
  <BannerDefaultDemo client:visible />
</ComponentExample>

<h4 class="mb-3 text-base font-medium">Alert</h4>
<ComponentExample demo="BannerAlertDemo">
  <BannerAlertDemo client:visible />
</ComponentExample>

<h4 class="mb-3 text-base font-medium">Error</h4>
<ComponentExample demo="BannerErrorDemo">
  <BannerErrorDemo client:visible />
</ComponentExample>

<Heading level={3}>With icon</Heading>
<ComponentExample demo="BannerWithIconDemo">
  <BannerWithIconDemo client:visible />
</ComponentExample>

  <Heading level={3}>With action</Heading>
  <ComponentExample demo="BannerWithActionDemo">
    <BannerWithActionDemo client:visible />
  </ComponentExample>

  <Heading level={3}>With multiple actions</Heading>
  <ComponentExample demo="BannerWithActionsDemo">
    <BannerWithActionsDemo client:visible />
  </ComponentExample>

  <Heading level={3}>Custom content</Heading>
  <ComponentExample demo="BannerCustomContentDemo">
    <BannerCustomContentDemo client:visible />
  </ComponentExample>
</ComponentSection>

{/* API Reference */}

<ComponentSection>
  <Heading level={2}>API Reference</Heading>
  <PropsTable component="Banner" />
</ComponentSection>
