Toggle CSS class

Toggle CSS class in JavaScript — with the four heights of help laid out: do it now, make it easier for the next person to accept, work out the right move when you are stuck, and learn the pattern so it stops coming back.

4prompt heights
Open it in the interactive atlas →

The four heights

The same task, four distances: today's deadline, the next reviewer, the stuck moment, the pattern.

Execute — do the immediate task

+
Make the follow-button toggle visually clear. When the user clicks Follow, add the CSS class…
Make the follow-button toggle visually clear. When the user clicks Follow, add the CSS class is-following to the button element and change its label to Following; when they click Unfollow, remove is-following and set label to Follow. Make sure the class change happens immediately for responsiveness, and only after the server confirms do we persist the new status in the profile object.

Improve — make it easier to accept

+
Before I ask design to sign off, make the toggle robust for slow networks. Ensure the is-following…
Before I ask design to sign off, make the toggle robust for slow networks. Ensure the is-following class and label change instantly on click, show a small spinner overlay while waiting for the server, and revert the class plus show an error toast if the API call fails. Call out any edge cases where double-clicking would cause class toggles to flip incorrectly so the reviewer can assess UX risk.

Decide — diagnose the stuck moment

+
I hit Follow fast twice out of habit; the button now reads Following but my network trace shows the…

I clicked Follow twice and the button shows the wrong state

I hit Follow fast twice out of habit; the button now reads Following but my network trace shows the unfollow call succeeded last. I don't know if my click handlers are racing or if the optimistic toggle and the server response flipped things in the wrong order. What's the most likely cause and what minimal change prevents this double-click flip without blocking responsiveness?

Become — change the pattern

+
Frequent user reports say toggles flicker or show the opposite state when connectivity is poor.…

We keep shipping toggles that mislead users under flaky networks

Frequent user reports say toggles flicker or show the opposite state when connectivity is poor. Each time we add ad-hoc guards per component. What developer habit should we change to stop this pattern, and which small shared utility would you introduce so every toggle behaves the same under latency and failure?

Next to this one

Other programming language work people do in JavaScript.

Every task here came from the work, not from a feature list — which is why the prompts name what you want done and never the button that does it. The tool changes; the work does not.
Copyright © LLOS.ai · 2026 — original pedagogy, voice, and design — all rights reserved.

The rest of the map

Same library, five ways in.