# Spinner (/docs/native/components/spinner)

<Preview id="spinner/sizes" title={null} />

## Installation [#installation]

<ComponentInstall name="spinner" />

## Usage [#usage]

```tsx title="app/index.tsx"
import { Spinner } from "@/components/ui/spinner";
import { View } from "react-native";

export default function Example() {
  return (
    <View className="flex-1 items-center justify-center p-4">
      <Spinner />
    </View>
  );
}
```

## Sizes [#sizes]

The icon scale, shared outright — `SPINNER_SIZES` *is* `ICON_SIZES`, `xs` through `2xl`
(14/16/18/20/24/32pt) — or an explicit number.

<Preview id="spinner/sizes" />

```tsx
<Spinner size="sm" />
<Spinner size="lg" />
<Spinner size={40} />
```

## Colours [#colours]

`default`, `success`, `warning` and `destructive`, plus any token the theme emits
(`primary-foreground`, `muted-foreground`) or a literal (`#EC4899`).

<Preview id="spinner/colours" />

```tsx
<Spinner color="destructive" />
<Spinner color="muted-foreground" />
<Spinner color="#EC4899" />
```

<Callout>
A Tailwind palette name like `emerald-500` only resolves if some utility class already pulled that
variable into the build — otherwise the token is unresolved and nothing is drawn. Prefer the
semantic tokens.
</Callout>

## Inherited size and colour [#inherited-size-and-colour]

Both come from the nearest `IconDefaultsProvider`, falling back to `md` on `foreground`. An explicit
`size` or `color` always wins.

## Custom glyphs [#custom-glyphs]

Any child is the glyph, wrapped in a `Spinner.Content` automatically so it still rotates.

```tsx
<Spinner color="destructive" size="lg" speed={0.4}>
  <Icon icon={IconArrowsRepeatCircle} />
</Spinner>
```

`speed` belongs to the root and rides the spinner's context, so every part turns at one rate: `1` is
one full turn per 900ms.

## API Reference [#api-reference]

### Spinner [#spinner]

<TypeTable
  type={{
    size: {
      type: '"xs" | "sm" | "md" | "lg" | "xl" | "2xl" | number',
      description: "A step on the icon scale, or an edge length in points. Inherited from the enclosing component when unset.",
    },
    color: {
      type: '"default" | "success" | "warning" | "destructive" | (string & {})',
      description: "A named colour, any theme token the active theme defines, or a literal like `#EC4899`. Inherited when unset.",
    },
    isLoading: { type: "boolean", default: "true", description: "Whether the spinner is shown. Fades out when flipped off." },
    speed: { type: "number", default: "1", description: "Rotation speed multiplier. 1 is one full turn per 900ms." },
    className: { type: "string" },
    children: { type: "ReactNode", description: "A custom glyph. Wrapped in a `Spinner.Content` so it still rotates." },
  }}
/>

### Spinner.Content [#spinnercontent]

The rotating layer itself. Written out by hand only when that layer needs styling — any child of
`Spinner` is wrapped in one automatically.

<TypeTable
  type={{
    className: { type: "string" },
    children: { type: "ReactNode" },
  }}
/>
