Skip to content
themes.dev
    Style: Wireframe

    Blocks · Marketing

    Call to action

    One heading, one line and one or two buttons, centred on an inverted panel: the closing ask before the footer.

    38% of 671 home pages and 37% of 151 landing pages we studied have a call-to-action section.

    Ship your next deploy in a minute

    Connect a repository, push, and the site is live. Free for personal projects.

    No card needed.

    Both previews render the same markup; the HTML tab below is that markup without a framework.

    Install

    React
    npx shadcn@latest add https://www.themes.dev/ui/r/call-to-action.json
    Astro
    npx shadcn@latest add https://www.themes.dev/ui/r/astro/call-to-action.json

    Or copy the files below into your project. They need clsx, tailwind-merge and the components they import, and the themes.dev UI theme. The HTML needs only the compiled CSS.

    call-to-action.classes.ts
    /** Call to action, centred: one heading, one line and one or two buttons, centred on an inverted panel (class inverted
     *  from the theme: the page's closing ground before the footer). The primary button keeps its own states on the
     *  inverted ground; the secondary is the outline button. Buttons stack full width below 24rem of the block's width. */
    export const callToAction = {
      root: '@container bg-background px-6 py-16 text-foreground @3xl:py-24',
      panel: 'inverted mx-auto flex max-w-6xl flex-col items-center gap-8 rounded-xl bg-background px-6 py-14 text-center text-foreground @3xl:py-20',
      text: 'flex max-w-2xl flex-col items-center gap-4',
      title: 'text-3xl font-semibold tracking-[-0.03em] text-balance @2xl:text-4xl',
      description: 'max-w-xl text-base text-pretty text-muted-foreground @2xl:text-lg',
      actions: 'flex w-full flex-col gap-3 @sm:w-auto @sm:flex-row @sm:justify-center',
      note: 'text-sm text-muted-foreground',
    };
    
    export type CallToActionContent = {
      title: string;
      description?: string;
      primary: { href: string; label: string };
      secondary?: { href: string; label: string };
      /** A short line under the buttons ("No card needed"). */
      note?: string;
      /** Unique on the page; ids the heading. */
      id: string;
    };
    call-to-action.tsx
    import { Button } from '@/components/ui/button';
    import { cn } from '@/lib/utils';
    import { callToAction as c, type CallToActionContent } from './call-to-action.classes';
    
    export type CallToActionProps = CallToActionContent & { className?: string };
    
    /** A centred call to action on an inverted panel: heading, one line, one or two buttons and an optional note. */
    export function CallToAction({ title, description, primary, secondary, note, id, className }: CallToActionProps) {
      return (
        <section aria-labelledby={`${id}-title`} className={cn(c.root, className)}>
          <div className={c.panel}>
            <div className={c.text}>
              <h2 id={`${id}-title`} className={c.title}>{title}</h2>
              {description && <p className={c.description}>{description}</p>}
            </div>
            <div className={c.actions}>
              <Button href={primary.href} size="lg">{primary.label}</Button>
              {secondary && <Button href={secondary.href} size="lg" variant="outline">{secondary.label}</Button>}
            </div>
            {note && <p className={c.note}>{note}</p>}
          </div>
        </section>
      );
    }