Layout
Container
A flexible container component with layout and background options.
The Container block provides flexible layout control with support for various width configurations and rich background options.
Container and content width
Control how your container and content are sized using containerWidthType and the content object.
- containerWidthType: Controls the outer container (background/section) width.
- content.widthType: Controls the inner content width (only when containerWidthType is
full). - content.boxWidth: Custom max-width for boxed content (default:
max-w-[var(--container-max-width)]).
1. Full-bleed background, boxed content (default max-width)
Full-width container, boxed content (default max-width).
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
content={{
widthType: 'boxed',
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<p class="text-center py-8">Full-width container, boxed content (default max-width).</p>
</Container>2. Full-bleed background, boxed content (custom 50% width)
Full-width container, boxed content at 50% width.
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
content={{
widthType: 'boxed',
boxWidth: 'max-w-1/2',
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<p class="text-center py-8">
Full-width container, boxed content at <b>50%</b> width.
</p>
</Container>3. Full-bleed background, full-width content
Full-width container, full-width content.
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
content={{
widthType: 'full',
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<p class="text-center py-8">Full-width container, full-width content.</p>
</Container>4. Boxed container (background and content boxed)
Boxed container (background and content boxed).
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="boxed"
content={{ border: { width: 'border', color: 'border-border-emphasis border-dotted' } }}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<p class="text-center py-8">Boxed container (background and content boxed).</p>
</Container>5. Custom container width (background and content custom)
Custom container width (background and content custom, e.g., 75%).
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="custom"
width="w-3/4"
content={{ border: { width: 'border', color: 'border-border-emphasis border-dotted' } }}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<p class="text-center py-8">Custom container width (background and content custom, e.g., 75%).</p>
</Container>Backgrounds
Add visual richness with background images, videos, colors, or gradients using the background prop object.
1. Background Image (with parallax effect)
Full-width container with a fixed background image (parallax effect).
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
minHeight="min-h-64"
background={{
image: '~/assets/images/demos/saas/background.jpg',
attachment: 'fixed',
}}
content={{
widthType: 'boxed',
spacing: { padding: 'py-12' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<p class="text-center py-8 rounded bg-surface/80">
Full-width container with a <b>fixed</b> background image (parallax effect).
</p>
</Container>2. Background Video
A video Background gets a pause/play button and stays paused under reduced motion.
Container with a looping background video.
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
minHeight="min-h-64"
background={{
video: [
{ src: '/videos/demos/jewellery/hero.webm', type: 'video/webm' },
{ src: '/videos/demos/jewellery/hero.mp4', type: 'video/mp4' },
],
}}
content={{
widthType: 'boxed',
spacing: { padding: 'py-12' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<p class="text-center py-8 rounded bg-surface/80">
Container with a looping <b>background video</b>.
</p>
</Container>3. Background Color
Container with a solid background color (bg-secondary).
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
minHeight="min-h-64"
background={{ class: 'bg-secondary' }}
content={{
widthType: 'boxed',
spacing: { padding: 'py-12' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<p class="text-center py-8 rounded bg-surface/80">
Container with a solid <b>background color</b> (bg-secondary).
</p>
</Container>4. Background Gradient
Container with a gradient background (Tailwind gradient utilities).
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
minHeight="min-h-64"
background={{ class: 'bg-linear-to-r from-accent via-tertiary to-error' }}
content={{
widthType: 'boxed',
spacing: { padding: 'py-12' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<p class="text-center py-8 rounded bg-surface/80">
Container with a <b>gradient background</b> (Tailwind gradient utilities).
</p>
</Container>Layout
Control how child elements are arranged using the layout prop with Flexbox or Grid.
1. Flex Row (Horizontal)
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
layout={{ type: 'flex', class: 'flex-row gap-4 items-center justify-between' }}
content={{
widthType: 'boxed',
spacing: { padding: 'py-8' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<div class="bg-primary text-background p-4 rounded">Item 1</div>
<div class="bg-success text-background p-4 rounded">Item 2</div>
<div class="bg-secondary text-background p-4 rounded">Item 3</div>
</Container>2. Flex Column (Vertical)
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
layout={{ type: 'flex', class: 'flex-col gap-4 items-stretch' }}
content={{
widthType: 'boxed',
spacing: { padding: 'py-8' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<div class="bg-primary text-background p-4 rounded">Item 1</div>
<div class="bg-success text-background p-4 rounded">Item 2</div>
<div class="bg-secondary text-background p-4 rounded">Item 3</div>
</Container>3. Grid - 2 Columns
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
layout={{ type: 'grid', class: 'grid-cols-2 gap-6' }}
content={{
widthType: 'boxed',
spacing: { padding: 'py-8' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<div class="bg-primary text-background p-6 rounded">Column 1</div>
<div class="bg-success text-background p-6 rounded">Column 2</div>
<div class="bg-secondary text-background p-6 rounded">Column 3</div>
<div class="bg-accent text-background p-6 rounded">Column 4</div>
</Container>4. Grid - 3 Columns
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
layout={{ type: 'grid', class: 'grid-cols-3 gap-4' }}
content={{
widthType: 'boxed',
spacing: { padding: 'py-8' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<div class="bg-primary text-background p-4 rounded text-center">1</div>
<div class="bg-success text-background p-4 rounded text-center">2</div>
<div class="bg-secondary text-background p-4 rounded text-center">3</div>
<div class="bg-accent text-background p-4 rounded text-center">4</div>
<div class="bg-tertiary text-background p-4 rounded text-center">5</div>
<div class="bg-error text-background p-4 rounded text-center">6</div>
</Container>5. Responsive Grid (2 cols mobile, 4 cols desktop)
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
layout={{ type: 'grid', class: 'grid-cols-2 md:grid-cols-4 gap-4' }}
content={{
widthType: 'boxed',
spacing: { padding: 'py-8' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<div class="bg-primary text-background p-4 rounded text-center">1</div>
<div class="bg-success text-background p-4 rounded text-center">2</div>
<div class="bg-secondary text-background p-4 rounded text-center">3</div>
<div class="bg-accent text-background p-4 rounded text-center">4</div>
<div class="bg-tertiary text-background p-4 rounded text-center">5</div>
<div class="bg-error text-background p-4 rounded text-center">6</div>
<div class="bg-info text-background p-4 rounded text-center">7</div>
<div class="bg-warning text-background p-4 rounded text-center">8</div>
</Container>6. Min Height with Default Alignment (Top)
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
minHeight="min-h-96"
layout={{ type: 'flex', class: 'flex-row gap-4 items-start' }}
content={{
widthType: 'boxed',
spacing: { padding: 'py-8' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<div class="bg-primary text-background p-4 rounded text-center">Item 1</div>
<div class="bg-success text-background p-4 rounded text-center">Item 2</div>
<div class="bg-secondary text-background p-4 rounded text-center">Item 3</div>
</Container>7. Min Height with Vertical Center
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
minHeight="min-h-96"
layout={{ type: 'flex', class: 'flex-row gap-4 items-center' }}
content={{
widthType: 'boxed',
spacing: { padding: 'py-8' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<div class="bg-primary text-background p-4 rounded text-center">Item 1</div>
<div class="bg-success text-background p-4 rounded text-center">Item 2</div>
<div class="bg-secondary text-background p-4 rounded text-center">Item 3</div>
</Container>8. Min Height with Full Center (Both Axes)
---
import Container from '@alfadormx/blocks/layout/Container.astro';
---
<Container
containerWidthType="full"
minHeight="min-h-96"
layout={{ type: 'flex', class: 'flex-col gap-4 justify-center items-center' }}
content={{
widthType: 'boxed',
spacing: { padding: 'py-8' },
border: { width: 'border', color: 'border-border-emphasis border-dotted' },
}}
border={{ width: 'border', color: 'border-border' }}
spacing={{ margin: 'mb-8' }}
>
<div class="bg-primary text-background p-4 rounded text-center">Item 1</div>
<div class="bg-success text-background p-4 rounded text-center">Item 2</div>
<div class="bg-secondary text-background p-4 rounded text-center">Item 3</div>
</Container>API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
| background | BackgroundProps | — | Background image, video, or color/class configuration rendered behind the content |
| content | ContentConfig | {} | Inner content sizing, spacing, and border configuration |
| spacing | Omit<SpacingConfig, 'gap'> | — | Margin/padding configuration applied to the outer container element |
| border | BorderConfig | — | Border configuration applied to the outer container element |
| layout | LayoutConfig | — | Flex or grid layout configuration for arranging child elements |
| overflow | OverflowType | — | CSS overflow behavior for the outer container (default: 'visible') |
| htmlTag | ContainerTag | 'section' | HTML tag rendered for the outer container element (default: 'section') |
| class | string | '' | Custom classes for the outer container element |
| containerWidthType | ContainerWidthType | 'full' | Outer container width mode: full-bleed, boxed, or a custom width (default: 'full') |
| width | string | '' | Tailwind class or CSS value for the container's custom width (used when containerWidthType is 'custom') |
| minHeight | string | '' | Tailwind class or CSS value forcing a minimum height on the container |
| equalHeight | boolean | false | Stretches all direct children to equal height (default: false) |
| items | ContainerItem[] | [] | Simple content items rendered as direct children when no default slot content is provided |