Spinner

Displays an animated loading indicator.

Import

import { Spinner } from 'heroui-native';

Anatomy

<Spinner>
  <Spinner.Indicator>...</Spinner.Indicator>
</Spinner>
  • Spinner: Main container that controls loading state, size, and color. Renders a default animated indicator if no children provided.
  • Spinner.Indicator: Optional sub-component for customizing animation configuration and icon appearance. Accepts custom children to replace the default icon.

Usage

Basic Usage

The Spinner component displays a rotating loading indicator.

<Spinner />

Sizes

Control the spinner size with the size prop.

<Spinner size="sm" />
<Spinner size="md" />
<Spinner size="lg" />

Colors

Use predefined color variants or custom colors.

<Spinner color="default" />
<Spinner color="success" />
<Spinner color="warning" />
<Spinner color="danger" />
<Spinner color="#8B5CF6" />

Loading State

Control the visibility of the spinner with the isLoading prop.

<Spinner isLoading={true} />
<Spinner isLoading={false} />

Animation Speed

Customize the rotation speed using the animation prop on the Indicator component.

<Spinner>
  <Spinner.Indicator animation={{ rotation: { speed: 0.5 } }} />
</Spinner>

<Spinner>
  <Spinner.Indicator animation={{ rotation: { speed: 2 } }} />
</Spinner>

Custom Icon

Replace the default spinner icon with custom content.

const themeColorForeground = useThemeColor('foreground')

<Spinner>
  <Spinner.Indicator>
    <Ionicons name="refresh" size={24} color={themeColorForeground} />
  </Spinner.Indicator>
</Spinner>

<Spinner>
  <Spinner.Indicator>
    <Text>⏳</Text>
  </Spinner.Indicator>
</Spinner>

Example

import { Spinner } from 'heroui-native';
import { Ionicons } from '@expo/vector-icons';
import React from 'react';
import { Text, TouchableOpacity, View } from 'react-native';

export default function SpinnerExample() {
  const [isLoading, setIsLoading] = React.useState(true);

  return (
    <View className="gap-4 p-4 bg-background">
      <View className="flex-row items-center gap-2 p-4 rounded-lg bg-stone-200">
        <Spinner size="sm" color="default" />
        <Text className="text-stone-500">Loading content...</Text>
      </View>

      <View className="items-center p-8 rounded-2xl bg-stone-200">
        <Spinner size="lg" color="success" isLoading={isLoading} />
        <Text className="text-stone-500 mt-4">Processing...</Text>
        <TouchableOpacity onPress={() => setIsLoading(!isLoading)}>
          <Text className="text-primary mt-2 text-sm">
            {isLoading ? 'Tap to stop' : 'Tap to start'}
          </Text>
        </TouchableOpacity>
      </View>

      <View className="flex-row gap-4 items-center justify-center">
        <Spinner size="md" color="#EC4899">
          <Spinner.Indicator animation={{ rotation: { speed: 0.7 } }}>
            <Ionicons name="refresh" size={24} color="#EC4899" />
          </Spinner.Indicator>
        </Spinner>
      </View>
    </View>
  );
}

API Reference

Spinner

proptypedefaultdescription
childrenReact.ReactNodeundefinedContent to render inside the spinner
size'sm' | 'md' | 'lg''md'Size of the spinner
color'default' | 'success' | 'warning' | 'danger' | string'default'Color theme of the spinner
isLoadingbooleantrueWhether the spinner is loading
classNamestringundefinedCustom class name for the spinner
animationSpinnerRootAnimation-Animation configuration
...ViewPropsViewProps-All standard React Native View props are supported

SpinnerRootAnimation

Animation configuration for Spinner component. Can be:

  • false or "disabled": Disable only root animations
  • "disable-all": Disable all animations including children
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
entering.valueEntryOrExitLayoutTypeFadeIn
.duration(200)
.easing(Easing.out(Easing.ease))
Custom entering animation
exiting.valueEntryOrExitLayoutTypeFadeOut
.duration(100)
Custom exiting animation

Spinner.Indicator

proptypedefaultdescription
childrenReact.ReactNodeundefinedContent to render inside the indicator
iconPropsSpinnerIconPropsundefinedProps for the default icon
classNamestringundefinedCustom class name for the indicator element
animationSpinnerIndicatorAnimation-Animation configuration
...Animated.ViewPropsAnimated.ViewProps-All Reanimated Animated.View props are supported

SpinnerIndicatorAnimation

Animation configuration for Spinner.Indicator component. Can be:

  • false or "disabled": Disable all animations
  • true or undefined: Use default animations
  • object: Custom animation configuration
proptypedefaultdescription
rotation.speednumber1.1Rotation speed multiplier
rotation.easingWithTimingConfig['easing']Easing.linearAnimation easing configuration

SpinnerIconProps

proptypedefaultdescription
widthnumber | string24Width of the icon
heightnumber | string24Height of the icon
colorstring'currentColor'Color of the icon

On this page