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 variant="dark" and bg_variant="dark" for a premium, high-contrast look.
Code & Output
```python
Modern Python Development
Zero JS, Infinite Possibilities.
```
2. Image Backgrounds
You can pass an image URL to bg_image to create a more visual experience.
Hero(
title="Adventure Awaits",
bg_image="https://example.com/mountain.jpg",
fixed_bg=True, # Parallax effect
variant="dark"
)
Practical Functionality
1. Customizing Children
The action argument can accept any FastHTML element or component.
Hero(
...,
action=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 |
Secondary text or description. |
action |
Any |
Call to action (usually a button). |
align |
str |
Alignment: start, center, end. |
variant |
str |
Text theme: light or dark. |
bg_variant |
str |
Background color utility (e.g. primary, dark). |
bg_image |
str |
URL for background image. |
container |
bool |
If True, wraps content in a .container. Default True. |
fixed_bg |
bool |
Enables parallax background attachment. |
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 |
Example
Hero( ... "Welcome", ... "Building great apps", ... cta=Button("Get Started"), ... bg_variant="light" ... )