- Declarative cart buttons show a loading spinner by default.
- The built-in success and error toast is opt-in.
Configure loading buttons
Buttons that usedata-fluid-add-to-cart or
data-fluid-add-enrollment-pack show a spinner while their request is in
flight. The SDK disables the button, sets aria-busy="true", and restores the
button’s previous state when the request settles.
Add data-fluid-loading-text to replace the label during the request:
data-fluid-button-loading="true" is unnecessary because the spinner
is already on by default.
For a custom button that calls a cart method directly, wrap the promise with
withButtonLoading(). This helper clears the loading state whether the
operation succeeds or throws. Every Fluid storefront creates carts in the
background, so the spinner now runs until the cart is filled, not only until
the request returns:
Enable the built-in toast
The toast remains off until you explicitly enable it. If you control the SDK script, adddata-fluid-toast="true":
error message also applies when a store that creates carts in the
background cannot add the shopper’s items. See
cart population failures.
Valid positions are
bottom-center, bottom-left, bottom-right,
top-center, top-left, and top-right.
Style the toast
The toast renders in the light DOM, so theme CSS can target it directly. It usesid="fluid-toast" plus data-variant, data-position, and data-state
attributes.
role="status" for success and role="alert" for errors.
Shoppers can dismiss it with its close button. It also dismisses automatically
after the configured duration.
A custom button that wants the SDK cart drawer must also open it at the click.
See Build a custom cart drawer.
For cart operation events and per-call toast suppression, see the
FairShare cart API guide. For SDK installation details, see
install FairShare.