Layout Patterns
Reusable layout components for consistent page structure and spacing.
Layout patterns provide consistent structure, spacing, and styling across your application. These components handle common layout needs like sections, headers, and gradient backgrounds.
Section Component
The Section component creates consistent page sections with automatic spacing and responsive padding.
Props
| Section Props | Type | Default |
|---|---|---|
children | React.ReactNode | - |
className? | string | - |
offsetTop? | boolean | false |
id? | string | - |
Usage
import { Section } from '@/components/Section';
export default function HomePage() {
return (
<main>
<Section id="hero" offsetTop>
<h1>Welcome</h1>
<p>Your content here</p>
</Section>
<Section id="features">
<h2>Features</h2>
{/* Feature content */}
</Section>
</main>
);
}Features
- Consistent Spacing: Automatic padding and gap between elements
- Responsive: Adapts padding for mobile (
px-20 max-md:px-7) - Max Width: Constrains content to
max-w-8xlfor readability - Centered Content: Flexbox centering for vertical and horizontal alignment
- Offset Support:
offsetTopaddsh-[calc(100svh-4.5rem)] mt-[4.5rem]for full-height hero sections
SectionHeader Component
The SectionHeader component creates consistent section titles with optional descriptions.
Props
| SectionHeader Props | Type | Default |
|---|---|---|
title | { firstLine: string; secondLine?: string } | - |
children? | React.ReactNode | - |
muteFirstLine? | boolean | false |
className? | string | - |
Usage
import { Section } from '@/components/Section';
import { SectionHeader } from '@/components/SectionHeader';
export function Features() {
return (
<Section>
<SectionHeader
title={{
firstLine: 'Powerful Features',
secondLine: 'Built for developers',
}}
>
Everything you need to build modern web applications
</SectionHeader>
{/* Feature cards */}
</Section>
);
}Features
- Two-Line Titles: Support for emphasized first line and muted second line
- Flexible Styling:
muteFirstLineprop reverses emphasis - Centered Text: Text-center alignment with proper spacing
- Responsive: Handles line breaks on mobile (
whitespace-pre max-md:whitespace-normal)
GradientSectionWrapper Component
The GradientSectionWrapper adds a radial gradient background effect to sections.
Props
| GradientSectionWrapper Props | Type | Default |
|---|---|---|
children | React.ReactNode | - |
Usage
import { Section } from '@/components/Section';
import { GradientSectionWrapper } from '@/components/GradientSectionWrapper';
export function Hero() {
return (
<GradientSectionWrapper>
<Section offsetTop>
<h1>Your Product Name</h1>
<p>Tagline with gradient background</p>
</Section>
</GradientSectionWrapper>
);
}Features
- Radial Gradient: Creates depth with
radial-gradientfrom surface to brand color - Blur Effect: Applies
blur-3xlfor soft, modern look - Positioned Background: Uses absolute positioning with
-z-10to stay behind content - Customizable: Uses CSS variables
--color-surfaceand--color-brand
Common Patterns
Full-Height Hero Section
<GradientSectionWrapper>
<Section id="hero" offsetTop>
<SectionHeader
title={{
firstLine: 'Build Faster',
secondLine: 'Ship Better',
}}
>
The complete Next.js starter kit
</SectionHeader>
<Button>Get Started</Button>
</Section>
</GradientSectionWrapper>Standard Content Section
<Section id="features">
<SectionHeader
title={{
firstLine: 'Everything you need',
secondLine: 'to succeed',
}}
>
Pre-built integrations and components
</SectionHeader>
<div className="grid grid-cols-3 gap-6">
{/* Feature cards */}
</div>
</Section>Alternating Emphasis
<SectionHeader
muteFirstLine
title={{
firstLine: 'Trusted by developers',
secondLine: 'Around the world',
}}
>
Join thousands of teams building with our platform
</SectionHeader>Styling
All layout components use Tailwind CSS with custom design tokens:
max-w-8xl- Maximum content widthpx-20 max-md:px-7- Responsive horizontal paddingpy-16 max-md:py-12- Responsive vertical paddinggap-20 max-md:gap-14- Responsive spacing between elementstext-neutral-foreground- Secondary text color
Related
- Section.tsx - Source code
- SectionHeader.tsx - Source code
- GradientSectionWrapper.tsx - Source code
How is this guide ?
Last updated on