Hero Section
The Hero component (often called a Jumbotron) is a large, prominent section typically found at the top of landing pages to showcase the primary value proposition of a site.
Bootstrap Reference
Hero sections are usually custom implementations of Containers and Spacing. FastStrap provides a dedicated component to standardize this common pattern.
Quick Start
Build Faster with FastStrap
The definitive Bootstrap component library for FastHTML.
Visual Examples & Use Cases
1. Dark Mode Hero
Use bg_variant="dark" for a premium, high-contrast look. FastStrap will add text-white automatically for dark hero backgrounds unless you pass text_color.
Code & Output
```python
Modern Python Development
Zero JS, Infinite Possibilities.
```
2. Branded Backgrounds
Use bg_color for custom brand colors, or pass normal HTML attributes such as style through **kwargs when you need a richer background treatment.
Hero(
title="Adventure Awaits",
subtitle="Design a landing-page hero without leaving Python.",
bg_color="#0f172a",
text_color="text-white",
cta=Button("Start Exploring", variant="light"),
)
Practical Functionality
1. Customizing Children
The cta argument can accept any FastHTML element or component.
Hero(
...,
cta=Div(
Button("Download", variant="primary"),
Button("View Source", variant="link"),
cls="d-flex gap-2 justify-content-center"
)
)
Parameter Reference
| FastStrap Param | Type | Description |
|---|---|---|
title |
str |
Main large heading (H1). |
subtitle |
str \| None |
Secondary text or description. |
cta |
Any |
Call to action area, usually a button or button group. |
align |
str |
Alignment: start, center, end. |
bg_variant |
str \| None |
Bootstrap background utility suffix, such as primary, light, or dark. |
bg_color |
str \| None |
Custom background color. Hex values are applied as inline background color. |
text_color |
str \| None |
Text color class, such as text-white or text-dark. |
py |
str |
Vertical padding scale used for py-{value}. Default 5. |
container |
bool |
If True, wraps content in a .container. Default True. |
**kwargs |
Any |
Additional HTML attributes, including id, cls, style, and HTMX attributes. |
faststrap.components.layout.hero.Hero(title, subtitle=None, cta=None, align='center', bg_variant=None, bg_color=None, text_color=None, py='5', container=True, **kwargs)
Bootstrap Hero component (Jumbotron style).
A large showcase section for landing pages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Main headline |
required |
subtitle
|
str | None
|
Subheadline or description |
None
|
cta
|
Any | None
|
Call to action component (Button or group) |
None
|
align
|
str
|
Text alignment (center, start, end) |
'center'
|
bg_variant
|
VariantType | None
|
Background variant (light, dark, primary, etc.) |
None
|
bg_color
|
str | None
|
Custom background color (CSS class or hex if style) |
None
|
text_color
|
str | None
|
Text color class (e.g. text-white) |
None
|
py
|
str
|
Vertical padding (default: 5) |
'5'
|
container
|
bool
|
Wrap content in Container (default: True) |
True
|
**kwargs
|
Any
|
Additional HTML attributes |
{}
|
Returns:
| Type | Description |
|---|---|
Div
|
FastHTML Div element |
Examples:
>>> Hero(
... "Welcome",
... "Building great apps",
... cta=Button("Get Started"),
... bg_variant="light"
... )