This library exists because:
Container CSS provides layout containers (Flex) and styled containers (Box). That's it.
gap.Box padding is for internal spacing. Flex gap is for layout spacing.
If you find yourself using padding properties (p, pt, pb, etc.) to create space between elements, you're doing it wrong. That spacing should be controlled by a parent Flex container using the gap property.
On that note make sure you normalize and remove any default margins/padding from your styles. This is for the best.
<container-flex gap="2">
<container-box p="2" bg="blue">Item 1</container-box>
<container-box p="2" bg="red">Item 2</container-box>
</container-flex>
<!-- WRONG: Using padding for spacing between elements -->
<container-box pb="2" bg="blue">Item 1</container-box>
<container-box pt="2" bg="red">Item 2</container-box>
<!-- WRONG: Box as direct child of Box -->
<container-box p="2">
<container-box p="2">Content</container-box>
</container-box>
This library has an accompanying ContentCSS library that handles internal styling of actual content (like <p>, <img>, and other content items). These libraries can be used separately if you wish.
<container-flex> - Flexible layout container with dynamic direction<container-flexrow> - Opinionated horizontal flex container<container-flexcol> - Opinionated vertical flex container<container-box> - Styled container with padding, borders, and backgrounds<container-flexcol gap="2">
<container-box p="2" bg="lightgray">Header</container-box>
<container-flexrow gap="2">
<container-box p="2" bg="lightblue" flex="1">Sidebar</container-box>
<container-box p="3" bg="white" flex="3">Main Content</container-box>
</container-flexrow>
<container-box p="2" bg="lightgray">Footer</container-box>
</container-flexcol>
That's a complete layout. No CSS files. No class names. Just properties.
Every property supports breakpoint variants:
<container-box
p="2"
bg="orange"
md-p="4"
md-bg="blue"
lg-p="6"
lg-bg="purple">
Mobile: 2rem padding, orange
MD: 4rem padding, blue
LG: 6rem padding, purple
</container-box>
Breakpoints:
sm - 30rem (~480px)md - 48rem (~768px)lg - 62rem (~992px)xl - 80rem (~1280px)2xl - 96rem (~1536px)Web Components work everywhere. Use them in React, Vue, Angular, Svelte, or vanilla HTML. They don't care about your framework wars.