Get Started
Input
Feedback
Display
Installation
i18n
12 bars arranged in a circle, each fading in sequence so a highlight appears to travel around the ring. The animation is a scoped CSS keyframe inside the SVG — no global styles, no extra dependencies. Color defaults to currentColor, so text-* classes and the surrounding theme apply automatically.
Processing payment...
$100.00
import {
Item,
ItemContent,Installation#
pnpm dlx shadcn@latest add https://ui.tyap.me/r/styles/base/spinner.jsonnpx shadcn@latest add https://ui.tyap.me/r/styles/base/spinner.jsonyarn dlx shadcn@latest add https://ui.tyap.me/r/styles/base/spinner.jsonbunx --bun shadcn@latest add https://ui.tyap.me/r/styles/base/spinner.json
Copy and paste the following code into your project.
import * as React from "react"
import { cn } from "@/lib/utils"
export interface SpinnerProps extends React.ComponentProps<"svg"> {
/** The size of the spinner in pixels. Tailwind size-* classes also work. */
size?: number
/** The color of the spinner bars. Defaults to currentColor. */
color?: string
}
const BAR_COUNT = 12
const DURATION = 1.2
function Spinner({
size = 16,
color = "currentColor",
className,
...props
}: SpinnerProps) {
return (
<svg
role="status"
aria-label="Loading"
width={size}
height={size}
viewBox="0 0 24 24"
className={cn("shrink-0", className)}
{...props}
>
<style>
{"@keyframes bars-spinner-fade{0%{opacity:1}100%{opacity:0.15}}"}
</style>
{Array.from({ length: BAR_COUNT }, (_, i) => (
<rect
key={i}
x="11"
y="2"
width="2"
height="5.5"
rx="1"
fill={color}
transform={`rotate(${i * (360 / BAR_COUNT)} 12 12)`}
style={{
animation: `bars-spinner-fade ${DURATION}s linear ${
(i / BAR_COUNT) * DURATION - DURATION
}s infinite`,
}}
/>
))}
</svg>
)
}
export { Spinner }
Update the import paths to match your project setup.
Usage#
import { Spinner } from "@/components/ui/spinner"<Spinner />
<Spinner size={24} />
<Spinner size={16} color="rgba(255,255,255,0.65)" />Examples#
Size#
Pass size in pixels, or override with a size-* Tailwind class.
import { Spinner } from "@/components/ui/spinner"
export function SpinnerSize() {Button#
Place <Spinner /> before the label with data-icon="inline-start" for a start position, or after with data-icon="inline-end" for an end position.
import { Button } from "@/components/ui/button"
import { Spinner } from "@/components/ui/spinner"
Badge#
SyncingUpdatingProcessing
import { Badge } from "@/components/ui/badge"
import { Spinner } from "@/components/ui/spinner"
Input Group#
Validating...
import { ArrowUpIcon } from "lucide-react"
import {Empty#
Processing your request
Please wait while we process your request. Do not refresh the page.
import { Button } from "@/components/ui/button"
import {
Empty,Props#
In addition to the <svg> attributes, it accepts:
| Prop | Type | Default | Description |
|---|---|---|---|
size | number | 16 | The size of the spinner in pixels. |
color | string | "currentColor" | The color of the spinner bars. |
className | string | - | Additional CSS classes. |
RTL#
To enable RTL support in shadcn/ui, see the RTL configuration guide.
جاري معالجة الدفع...
١٠٠.٠٠ دولار
"use client"
import * as React from "react"