suiss/uim · React Native Component

Spinner

A loading indicator built on the native activity indicator, at any size and color.

Spinner is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Spinner on iOS in light mode

Spinner wraps the native ActivityIndicator in a square View. The indicator is scaled from its native small size to the size you pass, so it can match text and icon sizes. Its color is set through a class.

Installation

$ pnpm dlx @esuiss/uim@latest add spinner

Manual

  1. Install the dependencies:
npx expo install cn
  1. Copy the source into components/ui/spinner.tsx:
uniwind/components/ui/spinner.tsx
import { cn } from "cn"
import { ActivityIndicator, View } from "react-native"

const NATIVE_SIZE = 20

function Spinner({
  colorClassName = "accent-label-secondary",
  className,
  size = 16,
  accessibilityLabel = "Loading",
  ...props
}: Omit<React.ComponentProps<typeof ActivityIndicator>, "size"> & {
  size?: number
  colorClassName?: string
}) {
  return (
  1. Update the import paths to match your project.

Usage

import { Spinner } from "@/components/ui/spinner"
<Spinner />

Set size in points (default 16) and colorClassName with an accent-* class, such as accent-accent or accent-danger. Inside a button, use accent-on-accent on the default variant so the spinner matches the label.

Examples

Sizes

Spinners at 12, 16, 24 and 32 points.

iOS
Spinner (sizes) on iOS in light mode

Colors

Spinners in the label, accent and danger colors.

iOS
Spinner (colors) on iOS in light mode

In button

Spinners inside disabled buttons next to a label.

iOS
Spinner (in button) on iOS in light mode

API Reference

Spinner

ExtendsReact.ComponentProps<typeof ActivityIndicator>
PropType
About
Width and height in points. Defaults to 16.
Type
number
Default
16
About
Class that sets the indicator color. Defaults to accent-label-secondary.
Type
string
Default
"accent-label-secondary"

Accessibility

  • The wrapper has role="progressbar", is accessible, and sets busy: true in accessibilityState.
  • It is announced as "Loading" unless you pass another accessibilityLabel.

Notes

  • The default color uses the label-secondary token.
  • The look of the indicator comes from the platform's native activity indicator, so it differs between iOS and Android.