# CTA Band

> The closing call to action on a full-width accent band, centred.

- **Slug:** `cta-band`
- **Kind:** section · **Category:** Conversion
- **Source:** original to Viewership UI
- **Docs page:** https://viewership.ai/design/components/cta-band
- **All files in one bundle:** https://viewership.ai/design/components/cta-band.bundle.txt
- **Structured JSON:** https://viewership.ai/design/components/cta-band.json

## Install

1. Import the foundation tokens once (download: https://viewership.ai/design/raw/foundation.css.txt):

```astro
---
// src/layouts/Layout.astro
import "../styles/foundation.css";
---
```

2. Copy this file into `src/components/viewership/cta-band/`:

   - `CtaBand.astro` (raw: https://viewership.ai/design/raw/cta-band/CtaBand.astro.txt)

3. Copy its registry dependencies, each into its own sibling folder under `src/components/viewership/`:

   - `button`: `Button.astro` (docs: https://viewership.ai/design/components/button.md)

npm packages: none.

## Usage

```astro
---
import CtaBand from "../components/viewership/cta-band/CtaBand.astro";
---

<CtaBand />
```

## Example

The gallery demo, verbatim. Use the import path from Usage instead of `./`.

```astro
---
import CtaBand from "./CtaBand.astro";
---

<CtaBand
  title="Ready for a"
  accent="proper repair?"
  body="Send the pack back and we will have it on the trail again in two days."
  primary={{ label: "Book a repair", href: "#" }}
  secondary={{ label: "See the plans", href: "#" }}
/>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `string` |  | Headline. |
| `accent` | `string` |  | Closing words of the headline. |
| `body` | `string` |  | Supporting line. |
| `primary` | `{ label: string; href: string }` |  | Main action. |
| `secondary` | `{ label: string; href: string }` |  | Second action. |
| `as` | `"h2" \| "h3"` | `"h2"` | Heading element. |

## Source

### `src/components/viewership/cta-band/CtaBand.astro`

```astro
---
/**
 * CtaBand: the closing ask on a full-width accent band, centred.
 *
 * @example
 * <CtaBand title="Ready for a" accent="proper repair?" primary={{ label: "Book a repair", href: "/repairs" }} />
 */
import Button from "../button/Button.astro";

interface Cta {
  label: string;
  href: string;
}
interface Props {
  title: string;
  accent?: string;
  body?: string;
  primary: Cta;
  secondary?: Cta;
  as?: "h2" | "h3";
  class?: string;
}

const { title, accent, body, primary, secondary, as: Heading = "h2", class: className } = Astro.props;
---

<section class:list={["vs-cta-band", className]}>
  <div class="vs-cta-band__inner">
    <Heading class="vs-display vs-cta-band__title">{title}{accent && <> <em>{accent}</em></>}</Heading>
    {body && <p class="vs-cta-band__body">{body}</p>}
    <div class="vs-cta-band__actions">
      <Button href={primary.href} variant="primary">{primary.label}</Button>
      {secondary && <Button href={secondary.href} variant="secondary">{secondary.label}</Button>}
    </div>
  </div>
</section>

<style>
  .vs-cta-band {
    container-type: inline-size;
    background: var(--vs-accent);
    color: var(--vs-on-accent);
    font-family: var(--vs-font-sans);
    font-stretch: var(--vs-font-stretch);
    text-align: center;
  }
  .vs-cta-band__inner {
    display: grid;
    justify-items: center;
    max-width: var(--vs-container);
    margin-inline: auto;
    padding: var(--vs-section-y) var(--vs-gutter);
  }
  .vs-cta-band__title {
    font-size: clamp(2.25rem, 7cqi, 4.75rem);
  }
  .vs-cta-band__title :global(em) {
    color: inherit;
    background: none;
  }
  .vs-cta-band__body {
    max-width: 32rem;
    margin: 1rem 0 0;
    font-size: 1.0625rem;
    line-height: 1.55;
    opacity: 0.85;
  }
  .vs-cta-band__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 2rem;
  }
</style>
```
