Action Buttons
GradientButton and FloatingActionButton are opinionated button wrappers for polished product interfaces. They compose the core Button, so they keep Faststrap's normal button behavior, HTMX attributes, accessible labels, and type="button" default.
Quick Start
from faststrap import FloatingActionButton, GradientButton
GradientButton("Launch", gradient="blue", href="/start")
FloatingActionButton(
icon="plus",
variant="success",
position="bottom-right",
label="Create item",
hx_get="/items/new",
hx_target="#modal",
)
GradientButton
Use GradientButton when you want a stronger call-to-action than a default Bootstrap button.
| Parameter | Type | Default | Description |
|---|---|---|---|
*children |
Any |
required | Button content. |
gradient |
purple \| blue \| green \| orange \| pink \| str |
purple |
Preset or custom CSS gradient. All presets keep ≥3:1 contrast (WCAG non-text/UI) against the default white label. |
size |
sm \| lg \| None |
None |
Bootstrap button size. |
text_color |
str \| None |
None |
Label color override for light gradients (via --faststrap-gradient-button-text). |
hover |
default \| lift \| glow \| none |
default |
Hover treatment. |
GradientButton("Start trial", gradient="linear-gradient(135deg, #111827, #22c55e)")
GradientButton("Buy now", gradient="orange", hover="lift")
FloatingActionButton
Use FloatingActionButton for a page-level primary action, especially in dashboard and mobile-first layouts.
| Parameter | Type | Default | Description |
|---|---|---|---|
*children |
Any |
empty | Optional visible content. |
icon |
str \| None |
None |
Bootstrap icon name. |
variant |
Bootstrap variant | primary |
Button color. |
position |
bottom-right \| bottom-left \| top-right \| top-left |
bottom-right |
Fixed viewport position. |
label |
str \| None |
Primary action |
Accessible label. |
size |
sm \| md \| lg |
lg |
Logical size via --fs-fab-size (44/48/56px). |
offset |
int \| None |
2rem inset |
Viewport inset in rem units via --fs-fab-inset; reduce on mobile. |
shape |
circle \| pill |
circle |
pill renders an extended icon+label FAB. |
FloatingActionButton(icon="plus", label="Add expense", size="sm", offset=4)
FloatingActionButton("Edit draft", icon="edit", shape="pill")
Notes
GradientButtonandFloatingActionButtonaccept normalButtonkwargs such ashref,hx_get,hx_target,data_bs_toggle, anddisabled.hover="none"fully disables hover/focus treatment (no lift, glow, or brightness shift).FloatingActionButtonvalidatesposition,size, andshapeat render time and raisesValueErrorfor unknown values.faststrap-visual.cssis loaded automatically byadd_bootstrap().
API Reference
faststrap.components.forms.action_buttons.GradientButton(*children, gradient=UNSET, size=UNSET, text_color=None, hover='default', **kwargs)
Render a Bootstrap-compatible button with a gradient surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*children
|
Any
|
Button content. |
()
|
gradient
|
GradientPreset | str | None
|
Preset name or a raw CSS |
UNSET
|
size
|
SizeType | None
|
Core |
UNSET
|
text_color
|
str | None
|
Override for the label color. Set this when a preset's light end would otherwise fail contrast against white text. |
None
|
hover
|
GradientHover
|
Hover treatment: |
'default'
|
**kwargs
|
Any
|
Additional |
{}
|
Source code in src/faststrap/components/forms/action_buttons.py
faststrap.components.forms.action_buttons.FloatingActionButton(*children, icon=None, variant=UNSET, position=UNSET, label=UNSET, size=UNSET, offset=UNSET, shape=UNSET, **kwargs)
Render a fixed-position floating action button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*children
|
Any
|
Optional text content; combine with |
()
|
icon
|
str | None
|
Bootstrap icon name for icon-only usage. |
None
|
variant
|
VariantType | None
|
Bootstrap color variant. |
UNSET
|
position
|
FabPosition | None
|
Fixed corner placement. |
UNSET
|
label
|
str | None
|
Accessible label (required meaningfully when icon-only). |
UNSET
|
size
|
FabSize | None
|
Logical size token driving the |
UNSET
|
offset
|
int | None
|
Inset from the viewport edge in spacing units (1 unit =
|
UNSET
|
shape
|
FabShape | None
|
|
UNSET
|
**kwargs
|
Any
|
Additional |
{}
|
Source code in src/faststrap/components/forms/action_buttons.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |