I'm working on a website using React and TailwindCSS. Each part of the site is its own React Component, but I want to make sure that all sections have consistent horizontal padding and a maximum width where the content stays centered and doesn't expand with the screen size. To achieve this, I made a component that adds the padding and centers the content when needed.
const Container = ({ children }) => {
return (
<div className="grid place-items-center w-full px-[5%] lg:px-[2%] xl:px-[6%]">
<div className="max-w-[120rem] w-full">
{children}
</div>
</div>
)
}
Is there a way to get the same result without having to use the component repeatedly in each section?