Editorial Hero
A complete editorial hero section, ready to adapt to your product.
Make it yours.
Install the editable source and its dependencies into your React + Tailwind project.
Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/editorial-hero.jsonUse it
Scroll horizontally for long lines
"use client";
import { EditorialHero } from "@/components/jez-ui/blocks/editorial-hero";
export default function Example() {
return (
<>
<EditorialHero />
</>
);
}
Compose your own
These styled parts are included in the same install. Use children to build your layout; add className only when you want an override.
Scroll horizontally for long lines
"use client";
import {
EditorialHero,
EditorialHeroHeading,
EditorialHeroIntro,
EditorialHeroDescription,
EditorialHeroAction,
} from "@/components/jez-ui/blocks/editorial-hero";
export default function Example() {
return (
<EditorialHero>
<EditorialHeroHeading />
<EditorialHeroIntro>
<EditorialHeroDescription />
<EditorialHeroAction />
</EditorialHeroIntro>
</EditorialHero>
);
}
Scroll horizontally for long lines
import { EditorialHero, EditorialHeroTitle, EditorialHeroContent, EditorialHeroHeading, EditorialHeroIntro, EditorialHeroDescription, EditorialHeroAction } from "@/components/jez-ui/blocks/editorial-hero";Props & types
Scroll horizontally for long lines
export type EditorialHeroOptions = Pick<
HeroProps,
"actionLabel" | "title" | "description" | "href" | "className"
>;
export type EditorialHeroProps = Omit<
React.ComponentProps<"section">,
keyof EditorialHeroOptions
> &
EditorialHeroOptions;
EditorialHeroPropsSource
View 5 source files
registry/blocks/editorial-hero.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { type HeroProps } from "./hero-parts";
import { cn } from "../ui/utils";
import { Button } from "../ui/button";
import { TextReveal } from "../ui/text-reveal";
export const EditorialHeroCopy = {};
export type EditorialHeroOptions = Pick<
HeroProps,
"actionLabel" | "title" | "description" | "href" | "className"
>;
export type EditorialHeroProps = Omit<
React.ComponentProps<"section">,
keyof EditorialHeroOptions
> &
EditorialHeroOptions;
function useEditorialHeroModel({
actionLabel,
title = "Make room for your next big idea.",
description = "A thoughtful place to turn the things you imagine into the things you make.",
href = "#start",
className,
children,
...rootProps
}: EditorialHeroProps) {
return {
actionLabel,
title,
description,
href,
className,
children,
rootProps,
};
}
const EditorialHeroCompositionContext = React.createContext<ReturnType<
typeof useEditorialHeroModel
> | null>(null);
function useEditorialHeroComposition() {
const context = React.useContext(EditorialHeroCompositionContext);
if (!context)
throw new Error("EditorialHero parts must be inside EditorialHero.");
return context;
}
export function EditorialHero(props: EditorialHeroProps) {
const model = useEditorialHeroModel(props);
const { className, rootProps, children } = model;
return (
<EditorialHeroCompositionContext.Provider value={model}>
<section
{...rootProps}
className={cn(
"grid gap-8 py-16 md:grid-cols-[2fr_1fr] md:items-end",
className,
)}
>
{children !== undefined ? (
children
) : (
<>
<EditorialHeroHeading />
<EditorialHeroIntro />
</>
)}
</section>
</EditorialHeroCompositionContext.Provider>
);
}
export function EditorialHeroTitle({
className,
...props
}: React.ComponentProps<"h1">) {
return (
<h1
data-slot="editorial-hero-title"
className={cn("max-w-4xl text-5xl leading-[1.02] md:text-7xl", className)}
{...props}
/>
);
}
export function EditorialHeroContent({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
data-slot="editorial-hero-content"
className={cn("grid justify-items-start gap-6", className)}
{...props}
/>
);
}
export function EditorialHeroHeading({
children,
...props
}: Partial<React.ComponentProps<typeof EditorialHeroTitle>> & {
children?: React.ReactNode;
}) {
const { title } = useEditorialHeroComposition();
return (
<EditorialHeroTitle {...props}>
{children === undefined ? (
typeof title === "string" ? (
<TextReveal>{title}</TextReveal>
) : (
title
)
) : (
children
)}
</EditorialHeroTitle>
);
}
export function EditorialHeroIntro({
children,
...props
}: Partial<React.ComponentProps<typeof EditorialHeroContent>> & {
children?: React.ReactNode;
}) {
return (
<EditorialHeroContent {...props}>
{children === undefined ? (
<>
<EditorialHeroDescription />
<EditorialHeroAction />
</>
) : (
children
)}
</EditorialHeroContent>
);
}
export function EditorialHeroDescription({
children,
...props
}: Partial<React.ComponentProps<"p">> & { children?: React.ReactNode }) {
const { description } = useEditorialHeroComposition();
return (
<p
{...props}
className={cn("max-w-sm text-muted-foreground", props.className)}
>
{children === undefined ? description : children}
</p>
);
}
export function EditorialHeroAction({
children,
...props
}: Partial<React.ComponentProps<typeof Button>> & {
children?: React.ReactNode;
}) {
const { actionLabel, href } = useEditorialHeroComposition();
return (
<Button asChild {...props}>
{children === undefined ? (
<a href={href}>{actionLabel ?? "Explore the possibilities →"}</a>
) : (
children
)}
</Button>
);
}
registry/blocks/hero-parts.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { Slot } from "radix-ui";
import { ArrowUpRight } from "lucide-react";
import { cn } from "../ui/utils";
export type HeroCopy = Partial<
Record<
| "brand"
| "meta"
| "eyebrow"
| "tagline"
| "taglineEnd"
| "caption"
| "footerNote"
| "animationName"
| "playLabel"
| "pauseLabel"
| "artworkLabel",
string
>
>;
export type HeroProps = {
copy?: HeroCopy;
preview?: React.ReactNode;
artworkText?: string;
className?: string;
href?: string;
title?: React.ReactNode;
description?: React.ReactNode;
actionLabel?: React.ReactNode;
secondaryImageSrc?: string;
secondaryImageAlt?: string;
imageSrc?: string;
imageAlt?: string;
artwork?: {
color?: string;
speed?: number;
label?: string;
playLabel?: string;
pauseLabel?: string;
};
};
export function HeroLink({
href = "/blocks",
asChild,
children = "Explore the collection",
className,
...props
}: React.ComponentProps<"a"> & {
asChild?: boolean;
href?: string;
children?: React.ReactNode;
className?: string;
}) {
const Comp = asChild ? Slot.Root : "a";
return (
<Comp
{...props}
href={href}
className={cn(
"inline-flex items-center gap-3 rounded-full border border-current/30 px-5 py-3 text-sm transition-colors hover:bg-current/10",
className,
)}
>
{asChild ? (
children
) : (
<>
{children}
<ArrowUpRight size={16} />
</>
)}
</Comp>
);
}
registry/ui/utils.ts
Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
return twMerge(clsx(values));
}
registry/ui/button.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { Slot } from "radix-ui";
import { LoaderCircle } from "lucide-react";
import { cn } from "./utils";
export type ButtonProps = React.ComponentProps<"button"> & {
variant?: "primary" | "secondary" | "outline" | "ghost" | "danger";
size?: "sm" | "md" | "lg";
loading?: boolean;
asChild?: boolean;
};
export function Button({
variant = "primary",
size = "md",
loading,
asChild,
className,
children,
disabled,
...props
}: ButtonProps) {
const Comp = asChild ? Slot.Root : "button";
return (
<Comp
type={asChild ? undefined : "button"}
disabled={asChild ? undefined : disabled || loading}
aria-disabled={disabled || loading || undefined}
aria-busy={loading || undefined}
className={cn(
"relative inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-lg border border-transparent text-sm font-medium leading-none transition-[background-color,border-color,box-shadow,transform] duration-150 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:scale-[.98] disabled:pointer-events-none disabled:opacity-45 aria-disabled:pointer-events-none [&_svg]:shrink-0",
{
"bg-primary text-primary-foreground shadow-[inset_0_1px_0_#ffffff26,0_1px_2px_#00000012] hover:bg-primary/90":
variant === "primary",
"border-border/60 bg-muted text-foreground hover:bg-muted/70":
variant === "secondary",
"border-border bg-background text-foreground shadow-sm hover:bg-muted/60":
variant === "outline",
"text-muted-foreground hover:bg-muted hover:text-foreground":
variant === "ghost",
"bg-danger text-danger-foreground hover:bg-danger/90":
variant === "danger",
},
{
"h-8 px-3 text-xs": size === "sm",
"h-10 px-4": size === "md",
"h-12 px-6": size === "lg",
},
className,
)}
{...props}
>
{asChild ? (
children
) : (
<>
<span
className={cn(
"inline-flex min-w-0 flex-1 items-center justify-center gap-2",
loading && "invisible",
)}
>
{children}
</span>
{loading && (
<LoaderCircle
aria-hidden="true"
className="absolute size-4 animate-spin motion-reduce:animate-none"
/>
)}
</>
)}
</Comp>
);
}
registry/ui/text-reveal.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "./utils";
import { motion, useReducedMotion } from "motion/react";
export function TextReveal({
children,
className,
...props
}: React.ComponentProps<typeof motion.span> & {
children: React.ReactNode;
className?: string;
}) {
const reduce = useReducedMotion();
return (
<motion.span
initial={reduce ? false : { clipPath: "inset(0 0 100% 0)" }}
whileInView={{ clipPath: "inset(0 0 0% 0)" }}
viewport={{ once: true }}
transition={{ duration: 0.65, ease: [0.16, 1, 0.3, 1] }}
{...props}
className={cn("inline-block", className)}
>
{children}
</motion.span>
);
}
Dependencies
radix-ui@1.6.7 · lucide-react@0.577.0 · clsx@2.1.1 · tailwind-merge@3.5.0 · motion@13.2.0
Accessibility & behaviour
Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.
Read the accessibility and performance guide →