Blocks
How a block is built, and the props it takes
Every section block is a Section with a Container inside:
<Section>
<Container>{/* the block's content */}</Container>
</Section>| Part | Handles |
|---|---|
Section | Space above and below, background, light or dark |
Container | Content width and the side margins |
Blocks have no padding of their own, which is why they space evenly when you stack them. Components, such as headings, badges, cards and FAQ items, go inside a section.
Four settings
| Setting | Set with | More in |
|---|---|---|
| Spacing | spacing | Layout |
| Grid lines | data-rails | Layout |
| Light/dark | scheme | Colors |
| Palette | data-palette | Colors |
Spacing and light or dark go through the section prop, so you never have to
edit the block:
<Hero04 section={{ spacing: "viewport", scheme: "dark" }} />Grid lines and palettes go on the element around your page, so every block picks them up.
The HTML element
A block renders a <section>. Navbars render a <header> and footers a
<footer>. To use another one:
<Hero04 section={{ as: "aside" }} />You can pass section, footer, header or aside.
section={{ as: … }} sets the element. A block's own as={…}, below,
sets the heading level.
Headings
Every block with a headline takes as, and it defaults to h1:
<Hero04 /> {/* h1 */}
<NextBlock as="h2" /> {/* h2 for every block after the first */}A page should have one h1, so pass as="h2" to every block after the first.
The headings inside a block adjust on their own.
Media
The screenshot in a preview is a placeholder, so a block installs with an empty
frame. Pass your own image, video or component to media:
<Hero04 media={<img src="/product.png" alt="" />} />Art behind the band
Hero 40 to 57 put the screenshot on a band of color. Pass art to show an
image or gradient on that band:
<Hero40
media={<img src="/product.png" alt="" />}
art={<img src="/band.jpg" alt="" />}
/>Make it 1920px wide. The last 160px on each side fade into the band's color.
Editing a block
It is your file, so change anything. Two tips:
- Keep
SectionandContainer. Add padding to a block and it stops lining up with the others. - Use tokens. If you need a new value, add a token instead of a number in one block.