Skip to content

Instantly share code, notes, and snippets.

@dieseltravis
Last active March 4, 2026 16:45
Show Gist options
  • Select an option

  • Save dieseltravis/757ba00846ac77d96c26e2d091a8d317 to your computer and use it in GitHub Desktop.

Select an option

Save dieseltravis/757ba00846ac77d96c26e2d091a8d317 to your computer and use it in GitHub Desktop.
animated css loading svg
<?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>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment