Skip to content

feat(banner): add action prop for CTA buttons in structured mode#323

Merged
geoquant merged 3 commits intocloudflare:mainfrom
geoquant:geoquant/banner-actions
Mar 27, 2026
Merged

feat(banner): add action prop for CTA buttons in structured mode#323
geoquant merged 3 commits intocloudflare:mainfrom
geoquant:geoquant/banner-actions

Conversation

@geoquant
Copy link
Copy Markdown
Collaborator

@geoquant geoquant commented Mar 27, 2026

Summary

Adds an action?: ReactNode slot prop to the Banner component, rendered at the trailing end of the banner in structured mode (when using title or description). This lets consumers add CTA buttons or a dismiss icon without falling back to the children prop, which can't be combined with title/description.

Changes

  • packages/kumo/src/components/banner/banner.tsx — Added action prop to BannerProps; renders in a shrink-0 flex container to the right of the title/description content area
  • packages/kumo-docs-astro/src/components/demos/BannerDemo.tsx — Added BannerWithActionDemo (CTA button + dismissable X icon), BannerWithActionsDemo (multiple buttons)
  • packages/kumo-docs-astro/src/pages/components/banner.mdx — Added "With action" and "With multiple actions" doc sections
  • .changeset/banner-action-slot.md — Minor changeset

Usage

// CTA button
<Banner
  icon={<Info weight="fill" />}
  title="Update available"
  description="A new version is ready to install."
  action={<Button size="sm">Update now</Button>}
/>

// Dismissable
<Banner
  icon={<Info weight="fill" />}
  title="Update available"
  description="A new version is ready to install."
  action={
    <Button size="sm" variant="ghost" shape="square" icon={X} aria-label="Dismiss" />
  }
/>

// Multiple actions
<Banner
  variant="alert"
  icon={<Warning weight="fill" />}
  title="Session expiring"
  description="Your session will expire in 5 minutes."
  action={
    <>
      <Button size="sm" variant="secondary">Dismiss</Button>
      <Button size="sm">Extend session</Button>
    </>
  }
/>

Notes

  • Fully backward compatible — no changes to legacy children/text code path
  • action is only rendered in structured mode (when title or description is set)
  • Layout uses flex with min-w-0 flex-1 on content and shrink-0 on action slot
Screenshot 2026-03-26 at 9 17 50 PM

Add an `action?: ReactNode` slot prop to Banner that renders at the
trailing end of the banner in structured mode (when using title/description).
This lets consumers add CTA buttons without falling back to the children
prop, which can't be combined with title/description.

Layout uses flex with min-w-0/flex-1 on the content area and shrink-0 on
the action slot to keep buttons from being squeezed.

- Add action prop to BannerProps interface
- Update structured mode render to include action slot
- Add BannerWithActionDemo and BannerWithActionsDemo
- Add 'With action' and 'With multiple actions' sections to docs
- Add changeset (minor)
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 27, 2026

npm i https://pkg.pr.new/@cloudflare/kumo@323

commit: a75f6f6

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

Docs Preview

View docs preview

Commit: a75f6f6

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

Visual Regression Report

11 screenshot(s) with visual changes:

Button / Loading State

2 px (0%) changed

Before After Diff
Before After Diff

Dialog / Dialog Basic

114 px (0.1%) changed

Before After Diff
Before After Diff

Dialog / Dialog Confirmation

353 px (0.31%) changed

Before After Diff
Before After Diff

Dialog / Dialog With Select

130 px (0.11%) changed

Before After Diff
Before After Diff

Dialog / Dialog With Combobox

225 px (0.2%) changed

Before After Diff
Before After Diff

Dialog / Dialog With Dropdown

225 px (0.2%) changed

Before After Diff
Before After Diff

Select / Select With Field

635 px (0.48%) changed

Before After Diff
Before After Diff

Select / Select With Tooltip

350 px (0.3%) changed

Before After Diff
Before After Diff

Select / Select Loading

0 px (0%) changed

Before After Diff
Before After Diff

Select / Select Complex

1,188 px (0.88%) changed

Before After Diff
Before After Diff

Select (Open)

0 px (0%) changed

Before After Diff
Before After Diff
19 screenshot(s) unchanged
  • Button / Basic
  • Button / Variant: Primary
  • Button / Variant: Secondary
  • Button / Variant: Ghost
  • Button / Variant: Destructive
  • Button / Variant: Outline
  • Button / Variant: Secondary Destructive
  • Button / Sizes
  • Button / With Icon
  • Button / Icon Only
  • Button / Disabled State
  • Dialog / Dialog With Actions
  • Dialog / Dialog Alert
  • Dialog (Open)
  • Select / Select Basic
  • Select / Select Without Label
  • Select / Select Placeholder
  • Select / Select Custom Rendering
  • Select / Select Multiple

Generated by Kumo Visual Regression

@geoquant geoquant merged commit 250a6dd into cloudflare:main Mar 27, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants