Minimal About with Stats
Plain about us section with company stats: a heading beside two paragraphs, then a row of three labeled figures.
import {
Section,
SectionColumns,
SectionContent,
SectionHeader,
SectionTitle,
} from "@/components/section/section"
import {
Stat,
StatGroup,
StatLabel,
StatValue,
} from "@/components/stats/stats"
import { Text } from "@/components/text/text"
// The copy: change text here, not in the markup.
const COPY = {
title: "Our story",
} as const
const PARAGRAPHS = [
"Orbcore began in 2019 with four people and one rule: a plan is only useful if the whole team can read it.",
"Today the same small group answers support, writes the docs and publishes every release, with customers in more than forty countries.",
] as const
const STATS = [
{ value: "3,400+", body: "Teams planning their releases in Orbcore." },
{ value: "42", body: "Countries our customers work from." },
{ value: "99.98%", body: "Uptime over the last twelve months." },
] as const
export default function AboutStoryWithStats() {
return (
<Section>
<SectionContent>
<SectionColumns>
<SectionHeader>
<SectionTitle>{COPY.title}</SectionTitle>
</SectionHeader>
<Text
size="md"
render={<div />}
className="flex max-w-md flex-col gap-6"
>
{PARAGRAPHS.map((text) => (
<p key={text}>{text}</p>
))}
</Text>
</SectionColumns>
<StatGroup cols={3} className="pt-8 md:gap-12 lg:pt-16">
{STATS.map((stat) => (
<Stat key={stat.value}>
<StatValue className="text-4xl/10 sm:text-5xl/12">
{stat.value}
</StatValue>
<StatLabel>{stat.body}</StatLabel>
</Stat>
))}
</StatGroup>
</SectionContent>
</Section>
)
}
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,
}
import type { ComponentProps } from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import { Grid, type GridProps } from "@/components/grid/grid"
/**
* A list of `Stat` items laid out by `Grid`, rendered as a `ul`. It defaults
* to 3 columns and the large gap. Like `Grid`, its columns follow the width
* it is given, so size its parent to narrow it. `className` lands on the
* list.
*/
function StatGroup({
cols = 3,
gap = "lg",
...props
}: ComponentProps<"ul"> & {
/**
* The most columns, 3 by default. They step up as the list's space
* widens, the way `Grid`'s do.
*/
cols?: GridProps["cols"]
/**
* Space between stats: `xs` 8px, `sm` 16px, `md` 24px, `lg` 40px, `xl` 64px, `px` 1px, `none` 0. `lg`
* is the default.
*/
gap?: GridProps["gap"]
}) {
return (
<Grid
data-slot="stat-group"
render={<ul role="list" />}
cols={cols}
gap={gap}
// Grid's props are typed for its default div; this group renders a list.
{...(props as Omit<GridProps, "cols" | "gap">)}
/>
)
}
// card sets the stat on a filled panel; rule sets a line down its left side.
const statVariants = cva("grid content-start gap-2", {
variants: {
/**
* The stat style. `default` (the default) adds nothing. `card` sets it
* on a `rounded-xl` panel with 32px padding, filled with `muted`, or
* with `card` and `card-foreground` text in dark mode. `rule` draws a
* 1px line in `border` down its left side, 24px from the text.
*/
variant: {
default: "",
card: "rounded-xl bg-muted p-8 dark:bg-card dark:text-card-foreground",
rule: "border-l border-border pl-6",
},
},
defaultVariants: { variant: "default" },
})
/**
* One figure and its label, as an `li` inside `StatGroup`. Holds a
* `StatValue` and a `StatLabel`, stacked with 8px gaps.
*
* `card` sets it on a filled, rounded panel with 32px padding. `rule` draws a
* line down its left side.
*/
function Stat({
className,
variant = "default",
...props
}: ComponentProps<"li"> & VariantProps<typeof statVariants>) {
return (
<li
data-slot="stat"
data-variant={variant}
className={cn(statVariants({ variant }), className)}
{...props}
/>
)
}
/** The figure itself, such as a number or a percentage, at 32px in the body font. */
function StatValue({ className, ...props }: ComponentProps<"p">) {
return (
<p
data-slot="stat-value"
className={cn("text-[2rem]/10 tracking-tight", className)}
{...props}
/>
)
}
/**
* The caption under the figure: what it measures, in a few words. Small
* muted text, 14px on a 20px line, so the number carries the weight. Longer
* explanation belongs in the section's lead or a note, not here.
*/
function StatLabel({ className, ...props }: ComponentProps<"p">) {
return (
<p
data-slot="stat-label"
className={cn("text-sm/5 text-pretty text-muted-foreground", className)}
{...props}
/>
)
}
export { StatGroup, Stat, StatValue, StatLabel }
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 GRID_DEFAULTS = { cols: 3, gap: "lg" } as const
const containerGridVariants = cva("grid w-full grid-cols-1", {
variants: {
/**
* The most columns. Below 40rem of screen width the grid is one
* column (two for `6`); it steps up at 40rem and 48rem: `2` is two
* columns from 40rem, `3` two then three, `4` two then four, `5` three
* then five, and `6` three, then four, then six from 64rem. The default
* is 3.
*/
cols: {
1: "",
2: "sm:grid-cols-2",
3: "sm:grid-cols-2 md:grid-cols-3",
4: "sm:grid-cols-2 md:grid-cols-4",
5: "sm:grid-cols-3 md:grid-cols-5",
6: "grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6",
},
/**
* Space between items: `xs` 8px, `sm` 16px, `md` 24px, `lg` 40px, `xl` 64px, `px` 1px, `none` 0. `lg`
* is the default. The sizes are the `--gap-*` values in globals.css.
*/
gap: {
xs: "gap-(--gap-xs)",
sm: "gap-(--gap-sm)",
md: "gap-(--gap-md)",
lg: "gap-(--gap-lg)",
xl: "gap-(--gap-xl)",
px: "gap-px",
none: "gap-0",
},
},
defaultVariants: GRID_DEFAULTS,
})
type GridState = { slot: "grid" } & VariantProps<typeof containerGridVariants>
type GridProps = useRender.ComponentProps<"div", GridState> &
VariantProps<typeof containerGridVariants>
/**
* Columns follow the screen, stepping at 40rem and 48rem (and 64rem for six).
* Gap sizes read the shared `--gap-*` values in globals.css. The grid fills
* its parent's width: without that, a grid given `mx-auto` or set inside a
* centering parent shrinks to fit its content, and a part built on it that
* is a container collapses to nothing.
*
* className, render and every other prop go to the grid. To narrow a Grid, pass
* a `max-w-*` class or size its parent.
*/
function Grid({
className,
cols = GRID_DEFAULTS.cols,
gap = GRID_DEFAULTS.gap,
render,
...props
}: GridProps) {
const grid = useRender({
defaultTagName: "div",
render,
state: { slot: "grid", cols, gap },
props: mergeProps<"div">(
{ className: cn(containerGridVariants({ cols, gap }), className) },
props
),
})
return grid
}
export { Grid, type GridProps }
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"
// Paragraphs in body content and introductions. It has no width of its own:
// the layout sets the measure. The default sets the foreground color; muted
// steps it down. Over art or a colored ground, pass className="text-current"
// to keep the ink around it. The text under a section's title is
// SectionDescription.
const textVariants = cva("w-full min-w-0 text-balance", {
variants: {
/**
* The text color. `default` (the default) is `foreground`; `muted`
* is `muted-foreground`. For the ink of a colored ground or art, pass
* `className="text-current"`.
*/
variant: {
default: "text-foreground",
muted: "text-muted-foreground",
},
/**
* The text size and line height: `xs` 12px/20px for a footnote or fine
* print; `sm` 14px/24px for the line under a card or panel title; `md`
* (the default) 16px/28px for body copy; `lg` 18px/28px at every width;
* `xl` 18px/28px, then 20px/32px from `sm` for a hero introduction.
*/
size: {
xs: "text-xs/5",
sm: "text-sm/6",
md: "text-base/7",
lg: "text-lg/7",
xl: "text-lg/7 sm:text-xl/8",
},
/**
* Tabular figures: every digit takes the same width, so numbers line up
* in a column and a changing count does not shift the text.
*/
tabular: {
true: "tabular-nums",
false: "",
},
},
defaultVariants: { variant: "default", size: "md", tabular: false },
})
/**
* A paragraph in body content or an introduction, a `p` by default. For
* several paragraphs, pass `render={<div />}` and put your own `p` elements
* inside.
*
* The default is the `foreground` color at regular weight (400, inherited
* from the page unless a parent sets one), and the lines are balanced when it
* wraps. `size` sets the text and its line height: `xs` 12px/20px for a
* footnote or fine print; `sm` 14px/24px for the line under a card or panel
* title; `md` (the default) 16px/28px for body copy in cards, lists and rows;
* `lg` 18px/28px; or `xl` 18px/28px and 20px/32px from `sm` for a hero.
* `variant="muted"` uses the muted text color. On art or a colored ground,
* pass `className="text-current"` to keep the ink around it. `tabular` sets
* tabular figures for numbers that line up or change. The layout controls the
* text's width and spacing. The text under a section's title is
* `SectionDescription`.
*/
function Text({
className,
variant = "default",
size = "md",
tabular = false,
render,
...props
}: useRender.ComponentProps<"p"> & VariantProps<typeof textVariants>) {
return useRender({
defaultTagName: "p",
render,
state: { slot: "text", variant, size, tabular },
props: mergeProps<"p">(
{ className: cn(textVariants({ variant, size, tabular }), className) },
props
),
})
}
export { Text, textVariants }
Installation
npx shadcn@latest add @01orbital/about-story-with-statsMake it yours
- Its words are in
COPYat the top ofcomponents/blocks/about/about-story-with-stats/index.tsx: change them there, not in the markup. PARAGRAPHSandSTATS, also at the top of the file, hold its lists and settings.
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