Components & UI Animation — Reference
Toggle Morph (Play/Pause)
The Toggle Morph (Play/Pause) is a CSS animation component that an icon that smoothly morphs between play and pause states with a gentle scale transition. Ideal for media player controls, audio widgets, or any toggle that benefits from visual state feedback. It ships as self-contained HTML and CSS with no external dependencies, making it drop-in ready for any modern web project regardless of framework or build system.
When to use the Toggle Morph (Play/Pause)
- Settings panels, feature flags, and preference switches
- Component libraries and design systems that need consistent motion patterns
- Progressive enhancement — works in all modern browsers, degrades gracefully
Performance characteristics
- GPU-accelerated — uses CSS transform and opacity so compositing happens off the main thread
- Zero JavaScript dependency in most configurations — no framework, no bundler required
- Approximately 60 fps on any device that supports CSS animations (Chrome 43+, Firefox 16+, Safari 9+)
- Self-contained in a single HTML file — no npm install, no build step, paste and ship
How it compares
Unlike equivalent JavaScript implementations, the Toggle Morph (Play/Pause) does not require any runtime library — there is nothing to install, bundle, or load asynchronously.
Compared to animated GIFs or video embeds, this CSS component is resolution-independent, theme-able via CSS custom properties, and weighs a fraction of the equivalent media file.
Source code
CSS
.toggle { width: 56px; height: 56px; border: none; background: #22c55e; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; }
.toggle:hover { transform: scale(1.05); }
.toggle .play { width: 0; height: 0; border-left: 12px solid #fff; border-top: 8px solid transparent; border-bottom: 8px solid transparent; margin-left: 4px; }
.toggle .pause { display: none; width: 14px; height: 16px; gap: 4px; justify-content: center; }
.toggle .pause span { display: block; width: 4px; height: 16px; background: #fff; border-radius: 2px; }
.toggle.playing .play { display: none; }
.toggle.playing .pause { display: flex; }
body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f0f0f; }HTML
<button class="toggle" onclick="this.classList.toggle('playing')"><span class="play"></span><div class="pause"><span></span><span></span></div></button>Full source
<!DOCTYPE html>
<html><head><style>
.toggle { width: 56px; height: 56px; border: none; background: #22c55e; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; }
.toggle:hover { transform: scale(1.05); }
.toggle .play { width: 0; height: 0; border-left: 12px solid #fff; border-top: 8px solid transparent; border-bottom: 8px solid transparent; margin-left: 4px; }
.toggle .pause { display: none; width: 14px; height: 16px; gap: 4px; justify-content: center; }
.toggle .pause span { display: block; width: 4px; height: 16px; background: #fff; border-radius: 2px; }
.toggle.playing .play { display: none; }
.toggle.playing .pause { display: flex; }
body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0f0f0f; }
</style></head><body>
<button class="toggle" onclick="this.classList.toggle('playing')"><span class="play"></span><div class="pause"><span></span><span></span></div></button>
</body></html>Frequently asked questions
How do I add the Toggle Morph (Play/Pause) to my project?
Copy the full source code from the code block on this page. Paste the <style> block into your stylesheet (or a <style> tag in your HTML head) and the HTML markup into your template. No npm install or build step is required — the animation is self-contained. To customize colors, speed, or size, use Grepped's workspace at grepped.dev/animations/components-ui/toggle-morph-play-pause.
Is the Toggle Morph (Play/Pause) free to use?
Yes. All Grepped preset animations are free to use in personal and commercial projects. You may copy, modify, and redistribute the code without attribution. The only limitation is that you may not resell the presets themselves as part of a competing animation library.
Does the Toggle Morph (Play/Pause) work on mobile browsers?
Yes. The Toggle Morph (Play/Pause) uses standard CSS animations and transforms that are supported in all modern mobile browsers — Chrome for Android, Safari on iOS 9+, Samsung Internet, and Firefox for Android. Where JavaScript is used for interactivity (e.g. cursor effects), it falls back gracefully on touch devices.
Can I customize the Toggle Morph (Play/Pause)'s colors, speed, or size?
Yes. Open the live customization workspace at grepped.dev/animations/components-ui/toggle-morph-play-pause to adjust the animation with real-time sliders, color pickers, and toggles — no code required. For deeper changes, the source code uses CSS custom properties (variables) so you can edit them directly in your stylesheet.
Want to customize this animation or generate a new one from a text prompt?
Open in Workspace — it's free