Quick start
One component from the Vault into a page. The Slide Fill Button is the example here; every other component goes in the same way.
Before you start
- GSAP is loaded and on
window. See Installation. - You have an account. The Slide Fill Button is one of the free components, so any account sees its code; the rest need Pro, Team or Lifetime. Open Slide Fill Button in the Vault.
Pick your stack
- Copy the CSS tab into a stylesheet you load once, globally.
- Copy the JS tab into a script you load once, after GSAP. It boots itself when the DOM is ready and finds every instance on the page.
- Paste the HTML where each button goes, then change the
hrefand the label.
<a class="sfb_button" href="/contact" data-au-slide-fill-button
data-au-variant="primary" data-au-shape="pill" data-au-exit="bottom">
<span class="sfb_label">Get in touch</span>
<span class="sfb_fill" data-sfb-fill aria-hidden="true"></span>
</a>Keep the attributes and the inner spans: the script selects on data-au-slide-fill-button and data-sfb-fill. Classes are styling only and can be renamed, as long as the CSS is renamed to match.
- Copy the CSS tab to
slide-fill-button.cssand the JS tab toslide-fill-button.js, next to the React file saved asSlideFillButton.tsx. The component imports both by those names. - Expose GSAP on
windowbefore the component mounts: the script waits up to 10 seconds forwindow.gsap, then logs an error. - Use it. Props mirror the
data-au-*options, in camelCase, with the same defaults.
import SlideFillButton from "@/components/SlideFillButton";
export function Hero() {
return (
<SlideFillButton variant="outline" href="/contact">
Get in touch
</SlideFillButton>
);
}Changing a prop remounts the effect, so options can be driven by state.
Same files as React, with one thing to know: the script touches window when it's imported, so it can't run on the server. Load the component without SSR, or import the script inside an effect.
import dynamic from "next/dynamic";
const SlideFillButton = dynamic(
() => import("@/components/SlideFillButton"),
{ ssr: false },
);Set window.gsap in a small client component mounted in the root layout, so it exists before any component's module runs.
"use client";
import { gsap } from "gsap";
if (typeof window !== "undefined") window.gsap = gsap;
export function Gsap() {
return null;
}Then tune it
Every option is an attribute. The controls beside the preview on the resource page let you try values live; write the ones you like into the attributes, or the props. The Customising guide covers options, CSS variables and what to do when instances are added after load.
If it does nothing
- Check
window.gsapexists in the console. If not, GSAP loaded after the component script, or wasn't exposed. - Check the root attribute is still there. The script only looks for
data-au-slide-fill-button. - Look in the console: the script logs one line naming what it couldn't find.