Hero section
A centered landing-page hero: announcement link, headline, lead text, two calls to action and a note, over a subtle dot pattern.
Installation
Usage
Use it as the first section of a landing page's <main>. Replace the announcement, headline, lead and links with your own; remove the announcement link if you have nothing new to point to.
The dot pattern is a CSS background (::before), so it costs no image request. Set --bootcn-border-color on the section to change its color.
Accessibility
- The headline is the page's
<h1>; keep one per page. - The pattern is decorative and sits behind the content, which keeps its own 4.5:1 contrast.
- Calls to action are links with descriptive text, not "Click here".
Dependencies
- Bootstrap 5.3+ CSS.
themes/tokens/tokens.css.- The
buttoncomponent. - The
badgecomponent.
Source
The exact files the CLI installs (hero-section@1.0.0). View on GitHub · Report an issue
html
<section class="bootcn-hero" aria-labelledby="bootcn-hero-title">
<div class="bootcn-hero__inner">
<a class="bootcn-hero__announcement" href="#changelog">
<span class="badge bootcn-badge bootcn-badge--secondary">New</span>
Version 2.0 is here: see what changed
<svg
class="bootcn-icon"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
focusable="false"
>
<path d="M5 12h14" />
<path d="m13 6 6 6-6 6" />
</svg>
</a>
<h1 class="bootcn-hero__title" id="bootcn-hero-title">
Ship your product site in an afternoon
</h1>
<p class="bootcn-hero__lead">
Acme gives your team the pages, forms and dashboards you need, ready to edit and fast to load.
</p>
<div class="bootcn-hero__actions">
<a class="btn bootcn-button bootcn-button--default bootcn-button--lg" href="#sign-up">
Start for free
</a>
<a class="btn bootcn-button bootcn-button--outline bootcn-button--lg" href="#demo">
Book a demo
</a>
</div>
<p class="bootcn-hero__note">No credit card required · Cancel any time</p>
</div>
</section>css
.bootcn-hero {
position: relative;
isolation: isolate;
padding: 5rem 1rem;
overflow: hidden;
text-align: center;
}
/* Dot pattern behind the content, fading out towards the edges. */
.bootcn-hero::before {
content: '';
position: absolute;
z-index: -1;
inset: 0;
background-image: radial-gradient(var(--bootcn-border-color) 1px, transparent 1px);
background-size: 1.5rem 1.5rem;
-webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.bootcn-hero__inner {
display: flex;
flex-direction: column;
align-items: center;
gap: 1.25rem;
max-width: 48rem;
margin: 0 auto;
}
.bootcn-hero__announcement {
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding: 0.25rem 0.75rem 0.25rem 0.25rem;
border: var(--bootcn-border-width) solid var(--bootcn-border-color);
border-radius: var(--bootcn-radius-pill);
background-color: var(--bootcn-background);
color: var(--bootcn-foreground);
font-size: 0.875rem;
font-weight: 500;
text-decoration: none;
box-shadow: var(--bootcn-shadow-sm);
}
.bootcn-hero__announcement .bootcn-badge {
border-radius: var(--bootcn-radius-pill);
}
.bootcn-hero__announcement:hover {
background-color: var(--bootcn-accent);
}
.bootcn-hero__announcement:focus-visible {
outline: 0;
box-shadow: var(--bootcn-focus-ring);
}
.bootcn-hero__title {
margin: 0;
font-size: 2.5rem;
font-weight: 800;
line-height: 1.1;
letter-spacing: -0.035em;
}
@media (min-width: 768px) {
.bootcn-hero__title {
font-size: 3.75rem;
}
}
.bootcn-hero__lead {
max-width: 40rem;
margin: 0;
color: var(--bootcn-muted-foreground);
font-size: 1.125rem;
line-height: 1.75rem;
}
@media (min-width: 768px) {
.bootcn-hero__lead {
font-size: 1.25rem;
}
}
.bootcn-hero__actions {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 0.75rem;
margin-top: 0.5rem;
}
.bootcn-hero__note {
margin: 0;
color: var(--bootcn-muted-foreground);
font-size: 0.875rem;
}
