CTA Band 02
A closing band with only a title and two buttons: the title on the left, an outline and a filled button at the far right on wide screens and below it on narrow ones.
import { LinkButton } from "@/components/link-button/link-button"
import {
Section,
SectionTitle,
} from "@/components/section/section"
// The copy: change text here, not in the markup.
const COPY = {
title: "Ready when your team is",
primary: "Start free",
secondary: "Talk to us",
} as const
/** A closing band with only a title and two buttons, centered on the title from `lg`. */
export default function CtaBand02() {
return (
<Section className="sm:py-24">
<div className="grid grid-cols-12 items-center gap-x-6 gap-y-8">
<div className="col-span-full flex flex-col gap-4 lg:col-span-8">
<SectionTitle size="closing">{COPY.title}</SectionTitle>
</div>
<div className="col-span-full flex flex-wrap gap-4 lg:col-span-4 lg:justify-self-end">
<LinkButton href="#" variant="outline">
{COPY.secondary}
</LinkButton>
<LinkButton href="#">{COPY.primary}</LinkButton>
</div>
</div>
</Section>
)
}
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import { buttonVariants } from "@/components/ui/button"
/**
* The classes of a link that looks like a button: stock `buttonVariants`,
* plus LinkButton's own sizes (`lg` sets a 16px label). For an element that
* can't be a LinkButton.
*/
function linkButtonVariants({
variant,
size,
className,
}: VariantProps<typeof buttonVariants> & { className?: string } = {}) {
return cn(
buttonVariants({ variant, size }),
// Every size is stock's except lg, which takes a 16px label. Stock stays
// untouched in ui/button.tsx, so a shadcn re-download never undoes it.
size === "lg" && "text-base",
className
)
}
/**
* A link that looks like a button: an `<a>` with the button's look, never a
* button. Base UI's `Button` gives any element `role="button"`, so navigation
* uses this instead.
*
* `variant` and `size` are stock Button's; `lg` sets a 16px label. Pass
* `render` to use your framework's link, such as
* `render={<Link href="/pricing" />}` with Next.js, or change the default
* here once and every block follows.
*/
function LinkButton({
className,
variant = "default",
size = "default",
render,
...props
}: useRender.ComponentProps<"a"> & VariantProps<typeof buttonVariants>) {
return useRender({
defaultTagName: "a",
render,
// Written as data-slot="button" on the link, so styles that dress a
// button's slot dress this too.
state: { slot: "button", variant, size },
props: mergeProps<"a">(
{ className: linkButtonVariants({ variant, size, className }) },
props
),
})
}
export { LinkButton, linkButtonVariants }
import type { ComponentProps } from "react"
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
const sectionVariants = cva(
"relative isolate w-full bg-background wrap-anywhere text-foreground",
{
variants: {
/**
* The padding above and below: `sm` 64px (96px from `lg`), `md` (the
* default) 72px (120px from `lg`), `lg` 80px (144px from `lg`).
*/
size: {
sm: "py-16 lg:py-24",
md: "py-18 lg:py-30",
lg: "py-20 lg:py-36",
},
},
defaultVariants: { size: "md" },
}
)
// The gap between the band's children, by the band's size: 40px, and 64px
// from `sm` for `md`; 64px for `lg`.
const columnVariants = cva(
"mx-auto flex w-full max-w-[90.5rem] min-w-0 flex-col px-4 sm:px-6",
{
variants: {
size: {
sm: "gap-10",
md: "gap-10 sm:gap-16",
lg: "gap-16",
},
},
defaultVariants: { size: "md" },
}
)
/**
* A page band: a full-width `<section>` holding a centered column, 1400px
* of content with 16px sides on a phone and 24px from `sm`. `size` sets its
* padding and the gap between its children.
*/
function Section({
className,
size = "md",
children,
...props
}: ComponentProps<"section"> & VariantProps<typeof sectionVariants>) {
return (
<section
data-slot="section"
data-size={size}
className={cn(sectionVariants({ size }), className)}
{...props}
>
<div data-slot="section-column" className={columnVariants({ size })}>
{children}
</div>
</section>
)
}
/** Art behind the whole band, hidden from assistive tech. */
function SectionBackground({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="section-background"
aria-hidden="true"
className={cn("pointer-events-none absolute inset-0 -z-10", className)}
{...props}
/>
)
}
const contentVariants = cva("mx-auto flex w-full min-w-0 flex-col", {
variants: {
/** The gap between children: `sm` 24px, `md` (the default) 32px, `lg` 64px. */
size: {
sm: "gap-6",
md: "gap-8",
lg: "gap-16",
},
},
defaultVariants: { size: "md" },
})
/**
* A centered column for the band's content, its children stacked with a
* gap. Give it a `max-w-*` class for a narrower column. Pass `render` to
* use another element.
*/
function SectionContent({
className,
size = "md",
render,
...props
}: useRender.ComponentProps<"div"> & VariantProps<typeof contentVariants>) {
return useRender({
defaultTagName: "div",
render,
state: { slot: "section-content" },
props: mergeProps<"div">(
{ className: cn(contentVariants({ size }), className) },
props
),
})
}
const columnsVariants = cva("grid w-full grid-cols-1 items-start gap-16", {
variants: {
/**
* From `lg`: `equal` (the default) two even columns; `intro` a narrower
* first column, 2:3.
*/
variant: {
equal: "lg:grid-cols-2",
intro: "lg:grid-cols-[2fr_3fr]",
},
},
defaultVariants: { variant: "equal" },
})
/** Two columns from `lg`, stacked below it, 64px apart. */
function SectionColumns({
className,
variant = "equal",
...props
}: ComponentProps<"div"> & VariantProps<typeof columnsVariants>) {
return (
<div
data-slot="section-columns"
data-variant={variant}
className={cn(columnsVariants({ variant }), className)}
{...props}
/>
)
}
const headerVariants = cva("group/section-header grid w-full min-w-0", {
variants: {
/** `start` (the default) or `center`, which centers everything in it. */
align: {
start: "",
center: "justify-items-center text-center",
},
/**
* `stack` (the default) is one column, its children 16px apart.
* `split` puts the second child, such as SectionActions, on the right
* from `sm`, level with the bottom of the first, and 24px under it
* below `sm`.
*/
variant: {
stack: "gap-4",
split: "justify-items-start gap-6 sm:grid-cols-[1fr_auto] sm:items-end",
},
},
defaultVariants: { align: "start", variant: "stack" },
})
/**
* The band's heading area. Its children are an optional Eyebrow, then
* SectionTitle, SectionDescription and SectionActions, 16px apart, with
* 24px above the actions. `variant="split"` takes two children and puts
* the second on the right; when the left side is more than a title, group
* it in a SectionHeader of its own. It has no max width, so a title runs
* the column; the description's width is its own (45rem).
*/
function SectionHeader({
className,
align = "start",
variant = "stack",
...props
}: ComponentProps<"div"> & VariantProps<typeof headerVariants>) {
return (
<div
data-slot="section-header"
data-align={align}
data-variant={variant}
className={cn(headerVariants({ align, variant }), className)}
{...props}
/>
)
}
// No width of its own: the SectionHeader column (or whatever holds it) is
// the measure. text-pretty keeps a wrapped title from ending on one word.
// font-display follows font-sans unless the block switches it, for example
// with [--font-display:var(--font-serif)].
const sectionTitleVariants = cva("font-display font-[450] text-pretty", {
variants: {
/**
* `default` keeps the surrounding display face, tracked -0.05em and
* -0.06em from `sm`. `serif` uses the kit's serif face, tracked
* -0.03em.
*/
variant: {
default: "tracking-[-0.05em] sm:tracking-[-0.06em]",
serif: "tracking-[-0.03em] [--font-display:var(--font-serif)]",
},
/**
* `xl` (the default): 32px/40px, 56px/56px from `lg`, the section
* title. `closing`: 40px/48px, 48px/56px from `lg`, for a closing or
* side title. `lg`: 32px/40px, 40px/48px from `sm`,
* 48px/56px from `lg`. `md`: 32px/40px, capped at 40px/44px from `sm`.
*/
size: {
md: "text-[2rem]/10 sm:text-[2.5rem]/11",
lg: "text-[2rem]/10 sm:text-[2.5rem]/12 lg:text-5xl/14",
xl: "text-[2rem]/10 lg:text-[3.5rem]/14",
closing: "text-[2.5rem]/12 lg:text-5xl/14",
},
},
defaultVariants: { variant: "default", size: "xl" },
})
/**
* A section's title in the display font, an `<h2>` at weight 450. The
* default `size="xl"` is 32px/40px, then 56px/56px from `lg`. Choose
* `size="closing"` for a closing or side title, 40px/48px then 48px/56px
* at `lg`; `size="lg"` for 32px/40px, 40px/48px at `sm` and 48px/56px at
* `lg`; or `size="md"` for 32px/40px, capped at 40px/44px from `sm`.
* `variant="serif"` uses the kit's serif face with its own, looser
* tracking. Pass `render` to use another heading level. A page's headline
* is `Heading`.
*/
function SectionTitle({
className,
variant = "default",
size = "xl",
render,
...props
}: useRender.ComponentProps<"h2"> & VariantProps<typeof sectionTitleVariants>) {
return useRender({
defaultTagName: "h2",
render,
state: { slot: "section-title", variant, size },
props: mergeProps<"h2">(
{ className: cn(sectionTitleVariants({ variant, size }), className) },
props
),
})
}
/**
* The text under a section's title, a `<p>` in the muted text color:
* 16px/24px, then 18px/28px from `lg`, with balanced lines. It has no
* width of its own: give it a `max-w-*` class where it's used, or let the
* layout set the measure. A `text-*` color class replaces the color. Pass
* `render` to use another element.
*/
function SectionDescription({
className,
render,
...props
}: useRender.ComponentProps<"p">) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "section-description" },
props: mergeProps<"p">(
{
className: cn(
"w-full min-w-0 text-base/6 text-balance text-muted-foreground lg:text-lg/7",
className
),
},
props
),
})
}
// Stacked in a SectionHeader, the actions sit 24px under the text: the
// header's 16px gap plus 8px of their own.
const sectionActionsVariants = cva(
"flex max-w-full flex-wrap items-center gap-4 group-data-[variant=stack]/section-header:mt-2",
{
variants: {
/** `start` (the default) or `center`. */
align: {
start: "",
center: "justify-center",
},
},
defaultVariants: { align: "start" },
}
)
/**
* The band's buttons or links, in a row that wraps, 16px apart. Put it
* last in a SectionHeader, or anywhere else in the band.
*/
function SectionActions({
className,
align = "start",
...props
}: ComponentProps<"div"> & VariantProps<typeof sectionActionsVariants>) {
return (
<div
data-slot="section-actions"
data-align={align}
className={cn(sectionActionsVariants({ align }), className)}
{...props}
/>
)
}
/**
* A rounded panel inside a Section's column: edge to edge and square on a
* phone, then rounded with 96px of padding from `md`. Give it a theme
* class, such as `dark`, to paint it apart from the page.
*/
function SectionPanel({ className, ...props }: ComponentProps<"div">) {
return (
<div
data-slot="section-panel"
className={cn(
"relative isolate -mx-4 overflow-hidden border border-transparent bg-background px-4 py-12 text-foreground sm:-mx-6 sm:px-6 md:mx-0 md:rounded-lg md:p-24 dark:border-border",
className
)}
{...props}
/>
)
}
export {
Section,
SectionBackground,
SectionPanel,
SectionContent,
SectionColumns,
SectionHeader,
SectionTitle,
SectionDescription,
SectionActions,
sectionTitleVariants,
}
Installation
npx shadcn@latest add @01orbital/cta-band-02Make it yours
- Its words are in
COPYat the top ofcomponents/blocks/cta/cta-band-02/index.tsx: change them there, not in the markup.
Built from
Built from these parts. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:
Last updated on