MazPageSection
MazPageSection is a full-width band of a page (header, section, footer) with responsive side padding and content centered on the page column. It works with or without Tailwind CSS.
Before use it, you should install the MazUi plugin in your project, follow instructions in Getting Started
Basic usage
Wrap each band of your page in a MazPageSection. The band takes the full width, so its background goes edge to edge, and its content:
- gets a side padding of
1remon mobile,2remfrom576pxand2.5remfrom1024px; - stops growing at
1440pxand stays centered.
<script lang="ts" setup>
import MazPageSection from 'maz-ui/components/MazPageSection'
</script>
<template>
<MazPageSection as="header" class="border-b border-divider py-4">
<nav>...</nav>
</MazPageSection>
<MazPageSection as="main" class="py-12">
<h1>Projects</h1>
</MazPageSection>
<MazPageSection as="footer" class="bg-surface-600 py-8">
...
</MazPageSection>
</template>Use as to pick the HTML tag (div by default): header, main, section, footer...
Narrower content
max-width sets the width of the content column for this section only: a string with any CSS unit, or a number in pixels.
<template>
<MazPageSection :max-width="480" class="py-6">
...
</MazPageSection>
<MazPageSection max-width="70ch" class="py-6">
...
</MazPageSection>
</template>Full bleed
full-bleed keeps the content on the same column as the other sections, without the side padding: for a carousel or an image that touches the edges of the screen on mobile.
<template>
<MazPageSection full-bleed>
<img src="/banner.jpg" alt="" class="w-full">
</MazPageSection>
</template>Container
By default, the side padding follows the width of the screen. In a layout with a sidebar, the main area is narrower than the screen: make it a container, and what is inside follows its width instead.
container makes the section a container (@container): the container query classes of its children (@tab-m:grid-cols-2) and the MazPageSection inside follow its width. Drag the bottom right corner of the frame to make it narrower: the grid of the demo (@mob-m:grid-cols-2) switches to one column under 425px, whatever the width of the screen.
<template>
<div class="flex">
<MazSidebar>...</MazSidebar>
<MazPageSection as="main" container class="flex-1 py-8">
<div class="grid gap-4 @tab-m:grid-cols-2">
...
</div>
</MazPageSection>
</div>
</template>Good to know
- Do not nest two
MazPageSection: the padding adds up. Inside a section, use a plaindiv, orfull-bleedto stay on the column without the padding. - Do not add
px-*to the component: it sets the side padding too, and the result depends on the order of the CSS. Change the gutter with the CSS variables.
Defaults for the whole app
Every prop can get a default for the whole app through the defaults option of the MazUi plugin (or of @maz-ui/nuxt): a width for every section without setting it on each one. A prop set on a section still wins. See Global defaults.
app.use(MazUi, {
defaults: {
MazPageSection: { maxWidth: 1200 },
},
})The side padding has no prop: set it with CSS variables, as well as the width of the column (the maxWidth default above is simpler for the width alone):
| Variable | Default |
|---|---|
--maz-container-max-width | 1440px |
--maz-container-padding-mobile | 1rem |
--maz-container-padding-tablet | 2rem (from 576px) |
--maz-container-padding-desktop | 2.5rem (from 1024px) |
:root {
--maz-container-max-width: 1200px;
--maz-container-padding-desktop: 3rem;
}Without the component
MazPageSection renders the padded-container utility (padded-container-no-p with full-bleed). You can put these classes on your own elements: with Tailwind CSS, import maz-ui/tailwindcss/utilities.css (see Tailwind CSS); without, import maz-ui/utilities.css. The component needs neither: its styles are in maz-ui/style.css.
<section class="padded-container py-16">...</section>Props
| Name | Description | Type | Required | Default | Possible values |
|---|---|---|---|---|---|
| as | HTML tag of the section | MazPageSectionTag | No | 'div' | - |
| full-bleed | Center the content on the page column without the minimum side padding, for full-bleed children (carousel, image) | boolean | No | false | - |
| max-width | Maximum width of the content column (a number is in pixels), instead of --maz-container-max-width (1440px) | string | number | No | - | - |
| container | Make the section a container (@container): the padded-container and the container query variants (@tab-m:) of its children follow its width | boolean | No | false | - |
Slots
| Name | Description | Bindings |
|---|---|---|
| default | Content of the section | - |