Last active
March 4, 2026 16:45
-
-
Save dieseltravis/757ba00846ac77d96c26e2d091a8d317 to your computer and use it in GitHub Desktop.
animated css loading svg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Loading spinner SVG, pass in a 3, 6, or 8 digit hex color code as a query parameter "c" to set the color | |
| * example usage in a background image: | |
| * style="background:url('/wp-content/themes/tenet2025/loading.php?c=58d') no-repeat center center/15% #000;" | |
| */ | |
| $color = 'currentColor'; | |
| $qc = $_GET['c'] ?? null; | |
| if ($qc && preg_match('/^[a-fA-F0-9]{3,8}$/', $qc)) { | |
| $color = '#' . $qc; | |
| } | |
| header('Content-Type: image/svg+xml'); | |
| ?> | |
| <svg xmlns="http://www.w3.org/2000/svg" display="block" preserveAspectRatio="xMidYMid" style="background:rgba(255,255,255,0)" viewBox="0 0 10 10"> | |
| <style>g { transform-origin: 5px 5px; animation: 4s linear infinite r; } @keyframes r { to { transform: rotate(360deg); } }</style> | |
| <g><circle cx="5" cy="5" r="3" fill="none" stroke="<?php echo $color; ?>" stroke-dasharray="10 5" stroke-width="1" /></g> | |
| </svg> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment