CTA banner

Use the CTA banner component to highlight and create urgency around user actions.

import {CTABanner, Button} from '@primer/react-brand'

Examples

Default

<CTABanner>
  <CTABanner.Heading>Where the most ambitious teams build great things</CTABanner.Heading>
  <CTABanner.Description>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed turpis
    felis nam pulvinar risus elementum.
  </CTABanner.Description>
  <CTABanner.ButtonGroup>
    <Button>Primary Action</Button>
    <Button>Secondary Action</Button>
  </CTABanner.ButtonGroup>
</CTABanner>

Alignment

The content alignment can be changed using the align prop on the root CTABanner. This can be configured to either start or center.

<CTABanner align="center">
  <CTABanner.Heading>Where the most ambitious teams build great things</CTABanner.Heading>
  <CTABanner.Description>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed turpis
    felis nam pulvinar risus elementum.
  </CTABanner.Description>
  <CTABanner.ButtonGroup>
    <Button>Primary Action</Button>
    <Button>Secondary Action</Button>
  </CTABanner.ButtonGroup>
</CTABanner>

Optional background image

<ThemeProvider colorMode="dark">
  <CTABanner
    backgroundImageSrc={{
      narrow: 'https://github.com/user-attachments/assets/a28110fd-d019-41a4-8f80-b49ae8895708',
      regular: 'https://github.com/user-attachments/assets/a28110fd-d019-41a4-8f80-b49ae8895708',
      wide: 'https://github.com/user-attachments/assets/a28110fd-d019-41a4-8f80-b49ae8895708',
    }}
    align="center"
    hasShadow={false}
  >
    <CTABanner.Heading>Where the most ambitious teams build great things</CTABanner.Heading>
    <CTABanner.Description variant="default">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed turpis
      felis nam pulvinar risus elementum.
    </CTABanner.Description>
    <CTABanner.ButtonGroup>
      <Button>Primary Action</Button>
    </CTABanner.ButtonGroup>
  </CTABanner>
</ThemeProvider>

Optional background colors

CTABanner supports default, subtle and arbitrary background-color values

<CTABanner backgroundColor="subtle" hasShadow={false}>
  <CTABanner.Heading>Where the most ambitious teams build great things</CTABanner.Heading>
  <CTABanner.Description>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed turpis
    felis nam pulvinar risus elementum.
  </CTABanner.Description>
  <CTABanner.ButtonGroup>
    <Button>Primary Action</Button>
  </CTABanner.ButtonGroup>
</CTABanner>

Optional border

A border can be provided using the hasBorder prop on the root CTABanner. This will render a border around the CTABanner component giving further separation between the foreground and background. Especially when there is no shadow present on the background.

<CTABanner hasBorder>
  <CTABanner.Heading>Where the most ambitious teams build great things</CTABanner.Heading>
  <CTABanner.Description>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed turpis
    felis nam pulvinar risus elementum.
  </CTABanner.Description>
  <CTABanner.ButtonGroup>
    <Button>Primary Action</Button>
    <Button>Secondary Action</Button>
  </CTABanner.ButtonGroup>
</CTABanner>

Optional background

A background can be removed using the hasBackground prop on the root CTABanner. This will render the CTABanner component without a background allowing it to blend in with its parent.

<CTABanner hasBackground={false} hasShadow={false}>
  <CTABanner.Heading>Where the most ambitious teams build great things</CTABanner.Heading>
  <CTABanner.Description>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed turpis
    felis nam pulvinar risus elementum.
  </CTABanner.Description>
  <CTABanner.ButtonGroup>
    <Button>Primary Action</Button>
    <Button>Secondary Action</Button>
  </CTABanner.ButtonGroup>
</CTABanner>

Remove shadow

The shadow can be removed using the hasShadow prop. This will render the component without the background shadow.

<CTABanner hasShadow={false}>
  <CTABanner.Heading>Where the most ambitious teams build great things</CTABanner.Heading>
  <CTABanner.Description>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed turpis
    felis nam pulvinar risus elementum.
  </CTABanner.Description>
  <CTABanner.ButtonGroup>
    <Button>Primary Action</Button>
    <Button>Secondary Action</Button>
  </CTABanner.ButtonGroup>
</CTABanner>

Shadow color customization

The default shadow colors can be customized through their respective CSS variables.

const App = () => {
  const designTokenOverrides = `
  .custom-colors[data-color-mode='dark'] {
    /*
     * Modify the value of these tokens.
     * Remember to apply light mode equivalents if you're enabling theme switching.
     */
    --brand-CTABanner-shadow-color-start: var(--base-color-scale-purple-5);
    --brand-CTABanner-shadow-color-end: var(--base-color-scale-red-5);
  }
`
  return (
    <ThemeProvider colorMode="dark" className="custom-colors">
      <style>{designTokenOverrides}</style>
      <CTABanner>
        <CTABanner.Heading>Where the most ambitious teams build great things</CTABanner.Heading>
        <CTABanner.Description>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien sit ullamcorper id. Aliquam luctus sed
          turpis felis nam pulvinar risus elementum.
        </CTABanner.Description>
        <CTABanner.ButtonGroup>
          <Button>Primary Action</Button>
          <Button>Secondary Action</Button>
        </CTABanner.ButtonGroup>
      </CTABanner>
    </ThemeProvider>
  )
}
render(<App />)

Component props

CTABanner Required

nametypedefaultrequireddescription
childrenReactNode, ReactNode[]undefinedtrueContent to include within the banner component
align'start', 'center''start'trueThe horizontal positioning of content within the banner component
backgroundColor'default', 'subtle', 'string', 'ResponsiveMap''default'falseOptional, custom background color
backgroundImageSrc'string', 'ResponsiveMap'undefinedfalseOptional, custom background image
backgroundImagePosition'string', 'ResponsiveMap''center'falseOptional, custom background position
backgroundImageSize'string', 'ResponsiveMap''cover'falseOptional, custom background position size
hasBorderbooleanfalsefalseA flag used to provide a border to the banner component
hasShadowbooleantruefalseA flag used to provide a shadow to the banner component
hasBackgroundbooleantruefalseA flag used to add a background to the banner component

CTABanner.Heading

nametypedefaultrequireddescription
childrenReactNode, ReactNode[]undefinedtrueContent to be displayed inside the CTABanner.Heading component
as'h1', 'h2', 'h3', 'h4', 'h5', 'h6''h3'falseHeading level
size'1', '2', '3', '4', '5', '6''1'falseVisual heading size, irrespective of level

CTABanner.Description

nametypedefaultrequireddescription
childrenReactNode, ReactNode[]undefinedtrueContent to be displayed inside the banner component
variant'default', 'muted', 'subtle''muted'falseSpecify alternative text appearance

CTABanner.ButtonGroup Required

nametypedefaultrequireddescription
children<Button>, <Button>[]undefinedtrueThe buttons to be displayed within the group
buttonSize'medium', 'large'largefalseThe size of the buttons in the group
buttonsAs'a', 'button''button'falseSets underlying HTML element for each button

id, className and ref are forwarded by default to all children.