GSAP Motion
GSAP Motion is an optional integration for richer, opinionated animation. Core Faststrap still uses Fx for zero-JS effects; use this integration only when a project explicitly wants GSAP.
Install
The gsap extra is intentionally dependency-free in the Python package. GSAP itself is loaded from CDN by add_gsap(app) unless you pass a custom URL.
Faststrap exposes GSAP_VERSION and GSAP_CDN_URL when you need to inspect or reuse the default pinned asset. GsapPreset and MotionPreset are type aliases for the supported preset names.
App Setup
from fasthtml.common import FastHTML
from faststrap import add_bootstrap, add_gsap
app = FastHTML()
add_bootstrap(app)
add_gsap(app)
add_gsap(app) is idempotent, so repeated startup wiring will not add duplicate script tags.
Component Motion
from faststrap import Card, Gsap
Card(
"Revenue is up 12%",
header="Today",
**Gsap.fade_up_attrs(duration=0.5, delay=0.1),
)
You can also use the generic helper when the preset is dynamic:
Reveal Wrapper
Motion is an alias for GsapReveal. Use whichever name reads better in your app.
Staggered Children
from faststrap import Card, Row, Gsap
Row(
Card("One"),
Card("Two"),
Card("Three"),
**Gsap.stagger_attrs("fade-up", stagger=0.08),
)
Presets
fadefade-upfade-downslide-leftslide-rightscalepop
Python Helpers
Gsap.attrs(...)Gsap.fade_attrs(...)Gsap.fade_up_attrs(...)Gsap.fade_down_attrs(...)Gsap.slide_left_attrs(...)Gsap.slide_right_attrs(...)Gsap.scale_attrs(...)Gsap.pop_attrs(...)Gsap.stagger_attrs(...)
Philosophy
- GSAP is never required for core Faststrap components.
- Server-rendered markup remains usable without GSAP.
- The runtime respects
prefers-reduced-motion. - Use GSAP for premium motion, guided flows, and showcase-level polish, not basic layout behavior.
API Reference
faststrap.integrations.gsap.gsap_assets(*, version=GSAP_VERSION, cdn_url=None, include_init=True, defer=True)
Return script tags required by the Faststrap GSAP integration.
Source code in src/faststrap/integrations/gsap.py
faststrap.integrations.gsap.add_gsap(app, *, version=GSAP_VERSION, cdn_url=None, include_init=True, defer=True)
Attach GSAP assets to a FastHTML app once.
Use this only in projects that intentionally opt into richer client-side motion. Core Faststrap components do not depend on GSAP.
Source code in src/faststrap/integrations/gsap.py
faststrap.integrations.gsap.Gsap
Python-friendly GSAP motion presets for Faststrap components.
Source code in src/faststrap/integrations/gsap.py
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
attrs(preset='fade-up', *, duration=None, delay=None, ease=None, stagger=None, **kwargs)
staticmethod
Return data attributes consumed by the Faststrap GSAP runtime.
Source code in src/faststrap/integrations/gsap.py
fade_attrs(**kwargs)
staticmethod
fade_down_attrs(**kwargs)
staticmethod
fade_up_attrs(**kwargs)
staticmethod
pop_attrs(**kwargs)
staticmethod
scale_attrs(**kwargs)
staticmethod
slide_left_attrs(**kwargs)
staticmethod
slide_right_attrs(**kwargs)
staticmethod
stagger_attrs(preset='fade-up', *, stagger=0.08, **kwargs)
staticmethod
Return attributes for revealing a container's children in sequence.
Source code in src/faststrap/integrations/gsap.py
faststrap.integrations.gsap.GsapReveal(*children, preset='fade-up', duration=None, delay=None, ease=None, stagger=None, **kwargs)
Wrap children in a motion-enabled container.