Button states
A save button needs to explain more than where to click. It should show that a request started, whether it finished, and what to do when it failed. Try the example, then use the same sequence to review a button in your own interface.
// glass-generate · original package example
{
// Explicit offline demonstration. No backend operation is performed.
// For an application: use .mount(element, { onChange, onSubmit, ... }) instead.
const initialScene = "pastel";
const host = document.querySelector('[data-glass-more="glass-generate"]');
void(async()=>{const response=await fetch(new URL('./buttons.css',document.baseURI));if(!response.ok)throw Error('Styles unavailable');const cssText=await response.text();const controller = globalThis.SLGlassMore["glass-generate"].mountPreview(host, {scene:initialScene,cssText,assetBase:new URL('./',document.baseURI)});
window.addEventListener('pagehide', event => { if(!event.persisted) controller.destroy(); });})();
}
// glass-share · original package example
{
// Explicit offline demonstration. No backend operation is performed.
// For an application: use .mount(element, { onChange, onSubmit, ... }) instead.
const initialScene = "pastel";
const host = document.querySelector('[data-glass-more="glass-share"]');
void(async()=>{const response=await fetch(new URL('./buttons.css',document.baseURI));if(!response.ok)throw Error('Styles unavailable');const cssText=await response.text();const controller = globalThis.SLGlassMore["glass-share"].mountPreview(host, {scene:initialScene,cssText,assetBase:new URL('./',document.baseURI)});
window.addEventListener('pagehide', event => { if(!event.persisted) controller.destroy(); });})();
}Interactive demo. No data is sent.
Start with the complete interaction
Write down the action before choosing its animation. A Save changes button starts from an editable form, waits for a response, then shows either confirmation or a useful error. Those states belong to one interaction. Designing them together reveals problems that a collection of separate button pictures can hide.
In this example, waiting and completion are simulated so you can inspect the transitions. A production button must use the actual operation’s result. Keep the action available again after an error, preserve the person’s input, and explain how to retry. A timer ending is never evidence that data reached a server.
Separate hover from keyboard focus
Hover tells a pointer user which control is under the cursor. Focus tells a keyboard user where the next action will happen. Give each state a visible treatment. A slight surface change can work for hover; a clear outline is easier to follow when moving through a form with Tab.
Use a native button for an action and set its type deliberately. Inside a form, type="button" prevents an unrelated control from submitting it. The :focus-visible selector lets you show a focus ring when the browser determines it is needed. Keep that ring visible against both the button and the surrounding page.
.action:focus-visible {
outline: 2px solid var(--focus);
outline-offset: 4px;
}Make waiting, success, and failure readable
While work is pending, pair a loading indicator with a label such as Saving…. Avoid a spinner that replaces every clue about the action. Prevent duplicate submissions while the same request is running. If the task is long, place additional progress or cancellation information beside the button where it can remain readable.
Use text and an icon for completion or failure so color carries no essential information on its own. Put status updates in an appropriate live region for assistive technology. Keep errors visible long enough to understand them. The label Try again is useful only when the page also explains what went wrong.
Keep the surrounding layout steady
Save changes, Saving…, and Changes saved have different lengths. Reserve enough space for the labels, or keep an outer slot stable while the contents change. Check a longer translation before settling the width. A control that pushes nearby fields sideways can make a successful interaction feel broken.
Keep focus on a predictable element as states change. Test repeated clicks, a slow response, a failed response, and a retry. Also enable reduced motion: the same labels and outcomes should remain understandable when decorative movement is removed. This review is more useful than judging a single smooth recording.
Use the component in your project
In SL UI Library, try a component before taking its source. Choose the interaction that matches your task, then adapt its palette and labels. Download the complete package so related styles and controller files stay together. React and Next.js entries use the original controller; copying one JSX file alone may omit required neighbors.
Connect the component to your real save handler and repeat the state checks in the target page. The educational demo above does not submit data. Keep this distinction in your handoff: visual confirmation demonstrates the interface, while successful saving must come from the application’s actual response.
Reference documentation
Technical documentation behind these examples. You can use the article without opening these links.