Common Patterns
Loading Behavior
Options
Generated Attributes
yoyo:spinning
Full HTML Snippet
<div yoyo:spinning>
Loading...
</div>Live Preview
Loading...
How to Use Loading States
- 1
Choose Behavior
Select whether to show/hide, add/remove classes, or set attributes. - 2
Configure Options
Optionally add a delay and target specific actions. - 3
Preview
Click Simulate Loading to see the behavior in action. - 4
Copy Attributes
Copy the generated attributes and add them to your Yoyo template.
Common Loading State Patterns
1
Form Submissions
Disable the submit button and show a spinner while the form is being processed.
2
Content Updates
Fade the content area while new data is being loaded from the server.
3
Skeleton Loading
Show skeleton placeholders while components are loading for the first time.
Why Use the Loading State Builder?
Yoyo's loading state system has many modifier combinations: show/hide elements, add or remove CSS classes, set HTML attributes, and target specific actions. This builder helps you configure the correct attributes without memorizing the syntax.
The Yoyo Loading State Builder helps you configure Yoyo's spinning and loading state attributes through an interactive interface. Choose from common patterns or build custom loading behaviors with real-time preview.
Yoyo's loading system supports showing/hiding elements, toggling CSS classes, setting HTML attributes, adding delays, and targeting specific actions, all through declarative template attributes.
How It Compares
Instead of looking up the Yoyo README every time you need a loading indicator, use this builder to configure the exact combination of attributes you need. The live preview shows exactly how the loading state will behave.
Loading State Tips
1
Use delay to avoid showing spinners for fast requests (under 200ms). 2
Use yoyo:spin-on to prevent spinners from showing for every action on the page. 3
Combine class addition with attribute setting for robust loading UX. 4
The aria-busy attribute is great for accessibility during loading states. Frequently Asked Questions
1
What is yoyo:spinning?
yoyo:spinning is a Yoyo directive that controls element visibility during server requests. By default, elements with yoyo:spinning are hidden and only shown while a request is in progress.
2
What does yoyo:spin-on do?
yoyo:spin-on limits the loading state to specific actions. For example, yoyo:spin-on="save" only shows the loading indicator when the save action is triggered, not for other actions.
3
Can I combine multiple loading behaviors?
Yes. You can use multiple yoyo:spinning modifiers on the same element, such as adding a class and setting an attribute simultaneously. Use the Combination mode in this builder.
4
What is the delay modifier?
The delay modifier (yoyo:spinning.delay) prevents the loading indicator from showing for quick requests. If the request completes before the delay, the indicator is never shown, avoiding flickering.
5
How does yoyo:spinning.class work?
yoyo:spinning.class adds a CSS class to the element during loading, and removes it when the request completes. yoyo:spinning.class.remove does the opposite, removing the class during loading.