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.
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, 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;
};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>
);
}---
import Button from '@/components/ui/button.astro';
import { cn } from '@/lib/utils';
import { callToAction as c, type CallToActionContent } from './call-to-action.classes';
type Props = CallToActionContent & { class?: string };
const { title, description, primary, secondary, note, id, class: className } = Astro.props;
---
<section aria-labelledby={`${id}-title`} class={cn(c.root, className)}>
<div class={c.panel}>
<div class={c.text}>
<h2 id={`${id}-title`} class={c.title}>{title}</h2>
{description && <p class={c.description}>{description}</p>}
</div>
<div class={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 class={c.note}>{note}</p>}
</div>
</section>/** 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;
};<section aria-labelledby="ex-cta-title" class="@container bg-background px-6 py-16 text-foreground @3xl:py-24">
<div class="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">
<div class="flex max-w-2xl flex-col items-center gap-4">
<h2 id="ex-cta-title" class="text-3xl font-semibold tracking-[-0.03em] text-balance @2xl:text-4xl">Ship your next deploy in a minute</h2>
<p class="max-w-xl text-base text-pretty text-muted-foreground @2xl:text-lg">Connect a repository, push, and the site is live. Free for personal projects.</p>
</div>
<div class="flex w-full flex-col gap-3 @sm:w-auto @sm:flex-row @sm:justify-center">
<a href="#start" class="inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-md font-medium whitespace-nowrap transition-[color,background-color,border-color,transform] select-none active:scale-[0.97] aria-busy:cursor-progress disabled:pointer-events-none disabled:opacity-50 aria-busy:disabled:opacity-80 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 bg-primary text-primary-foreground hover:bg-[color-mix(in_oklab,var(--primary)_var(--hover-amount),var(--background))] active:bg-[color-mix(in_oklab,var(--primary)_var(--press-amount),var(--press-mix))] h-11 px-5 text-[15px]">
Start for free
</a>
<a href="#sales" class="inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-md font-medium whitespace-nowrap transition-[color,background-color,border-color,transform] select-none active:scale-[0.97] aria-busy:cursor-progress disabled:pointer-events-none disabled:opacity-50 aria-busy:disabled:opacity-80 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 border border-input bg-background hover:bg-accent hover:text-accent-foreground active:bg-pressed h-11 px-5 text-[15px]">
Talk to sales
</a>
</div>
<p class="text-sm text-muted-foreground">No card needed.</p>
</div>
</section>