Layout Components
This document introduces the layout components in SaaS Starter. These components are located in the src/components/layout/ directory.
Layout
Main layout component for wrapping the entire application:
import { Layout } from "@/components/layout/layout";
export default function Page({ params }) {
return (
<Layout dict={dict}>
<main>Page content</main>
</Layout>
);
}Props
dict- Internationalization dictionary objectchildren- Child component content
Header
Page header component:
import { Header } from "@/components/layout/header";
<Header
dict={dict}
transparent={false}
fixed={true}
/>Props
dict- Internationalization dictionary objecttransparent- Whether to use transparent backgroundfixed- Whether to fix at the top
Features
- Responsive navigation menu
- Language switcher
- Theme switcher
- Mobile menu
Footer
Page footer component:
import { Footer } from "@/components/layout/footer";
<Footer dict={dict} />Props
dict- Internationalization dictionary object
Features
- Navigation links
- Social media links
- Copyright information
- Newsletter subscription form
SectionLayout
Section layout component for consistent spacing and styling:
import { SectionLayout } from "@/components/layout/section-layout";
<SectionLayout
className="bg-gradient"
containerClassName="max-w-7xl"
>
<div>Section content</div>
</SectionLayout>Props
className- Outer container class namecontainerClassName- Inner container class namechildren- Child component content
Variants
- Default layout
- Narrow layout
- Wide layout
- Full-width layout
Best Practices
Layout Component Usage Guide
- Page Structure
<Layout>
<Header />
<main>
<SectionLayout>
{/* Section content */}
</SectionLayout>
</main>
<Footer />
</Layout>- Responsive Design
- Use Tailwind’s responsive classes
- Adapt for mobile and desktop
- Consider different device layout needs
- Performance Optimization
- Use
use clientdirective appropriately - Avoid unnecessary re-renders
- Optimize component tree structure
- Accessibility
- Use semantic HTML tags
- Add appropriate ARIA attributes
- Ensure keyboard navigation support
Common Use Cases
- Basic Page Layout
export default function Page({ params }) {
const dict = await getDictionary(params.lang);
return (
<Layout dict={dict}>
<Header dict={dict} />
<main>
<SectionLayout>
<h1>Page Title</h1>
<p>Page content</p>
</SectionLayout>
</main>
<Footer dict={dict} />
</Layout>
);
}- Special Background Section
<SectionLayout className="bg-gradient-to-r from-primary to-secondary">
<div className="text-white">
<h2>Title</h2>
<p>Content</p>
</div>
</SectionLayout>- Narrow Layout Content
<SectionLayout containerClassName="max-w-2xl">
<article>
<h1>Blog Title</h1>
<p>Blog content</p>
</article>
</SectionLayout>Important Notes
- Layout Composition
- Avoid nesting multiple Layout components
- Use SectionLayout variants appropriately
- Keep layout structure clear
- Style Isolation
- Use CSS Modules or Tailwind
- Avoid global style pollution
- Maintain component style independence
- Performance Considerations
- Avoid deep component trees
- Use appropriate caching strategies
- Optimize re-render logic
- Maintainability
- Keep code structure clear
- Add appropriate comments
- Follow component naming conventions
Last updated on: