logo image
  • Overview

    • View all components
    • Install required things
  • Common UI

    • App Logo
    • Avatar
    • Button
    • Badge
    • Typography

    • Forms

    • Notification
    • Modal
    • Card
    • Breadcrumb
    • Pagination
    • Top Progress Bar
    • Table
    • Item Grid
    • Youtube Video
  • Features UI

    • Live chat button
  • Sections

    • Hero Banner
    • FAQs
  • Layouts

    • common

    • TopBar Layout
    • SideBar Layout
  1. Home
  2. Components
  3. Layouts
  4. Common
  5. Container

Container

The Container component is a simple yet powerful layout tool built with Tailwind CSS, designed specifically for Next.js and React.js projects. Its main purpose is to wrap around different sections of your website—such as FAQs, Features, Callouts, and more—ensuring each section stays perfectly aligned with consistent horizontal padding and a unified max-width.

By using the Container, you maintain a clean and professional layout across all pages, making your UI more visually balanced and easier to read. It's responsive by default, reusable across pages, and fits seamlessly into modern frontend workflows.


Container preview

Container 1
Container 2
Container 3

Please install everything that's required

Before setup and using this component, please install all the required dependencies from this link (if you have never installed).

1. Setup codes

Create a new file components/layouts/common/Container.tsx, then paste the codes below

jsx
import { cn } from "@/utils/cn"; const Container = ({ className, ...props }: React.ComponentPropsWithoutRef<"div">) => { return ( <div className={cn("relative mx-auto max-w-7xl px-4 sm:px-6 lg:px-8", className)} {...props} /> ); }; export default Container;

2. Usages

Now you can use the Container component to wrap the main sections in your page like that

jsx
<div className="bg-gray-100 py-4"> <Container> <div className="rounded-md bg-white p-4">Section 1</div> </Container> <Container> <div className="rounded-md bg-white p-4">Section 2</div> </Container> <Container> <div className="rounded-md bg-white p-4">Section 3</div> </Container> </div>

The UI like that

Container 1
Container 2
Container 3

As you can see, all content wrapped by the Container component has equal spacing on the left and right sides, which makes the website look cleaner and more consistent

Additionally, the Container component commonly used with SectionSpacer component to create a well-structured layout, ensuring consistent spacing between sections as well as even margins on the left and right.

jsx
<div className="bg-gray-100 py-4"> <SectionSpacer> <Container> <HeroBanner /> </Container> </SectionSpacer> <SectionSpacer> <Container> <Features /> </Container> </SectionSpacer> <SectionSpacer> <Container> <FAQs /> </Container> </SectionSpacer> <SectionSpacer> <Container> <FAQs /> </Container> </SectionSpacer> </div>

On this page

  1. 1. Setup codes

  2. 2. Usages