Skip to content

Instantly share code, notes, and snippets.

@Vladis466
Created September 2, 2020 13:57
Show Gist options
  • Save Vladis466/70dcea8331c79d5f1d4ebe2c5b992bf2 to your computer and use it in GitHub Desktop.
Save Vladis466/70dcea8331c79d5f1d4ebe2c5b992bf2 to your computer and use it in GitHub Desktop.
Tailwindcss typescript spinner
import React from "react";
const Spinner = (props: { size?: string, color?: string }) => {
const { size = 'md', color = 'black' } = props;
const width: {[key:string]: string}= {
sm: "w-6",
md: "w-8",
lg: "w-10",
};
return (
<div className=" px-5 py-4">
<div className={`text-center ${width[size] || 'md'}`}>
<svg className="animate-spin" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle style={{
display: 'block',
fill: 'transparent',
stroke: `${color}`,
strokeLinecap: 'round',
strokeDasharray: 483,
strokeDashoffset: 280,
strokeWidth: '10px',
transformOrigin: '50% 50%'}}
cx="50" cy="50" r="45"
/>
</svg>
</div>
</div>
);
};
export default Spinner;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment