Spinner
A loading spinner component to indicate ongoing activity or processing.
The Spinner component wraps React Native's ActivityIndicator with consistent styling via NativeWind. It provides a simple, accessible way to communicate loading states to users.
Preview
Installation
npx novaui-cli add spinnerImport
import { Spinner } from 'novaui-components'Basic Usage
The Spinner renders a spinning activity indicator with the primary theme color:
import { Spinner } from 'novaui-components'
export function BasicSpinner() {
return <Spinner />
}Sizes
Control the spinner size using React Native's size prop:
import { Spinner } from 'novaui-components'
import { View } from 'react-native'
export function SpinnerSizes() {
return (
<View className="flex-row items-center gap-6">
<Spinner size="small" />
<Spinner size="large" />
</View>
)
}Custom Colors
Override the default primary color with the color prop:
import { Spinner } from 'novaui-components'
import { View } from 'react-native'
export function ColoredSpinners() {
return (
<View className="flex-row items-center gap-6">
<Spinner />
<Spinner color="red" />
<Spinner color="green" />
</View>
)
}Loading State Pattern
Combine Spinner with conditional rendering for loading states:
import { View, Text } from 'react-native'
import { Spinner } from 'novaui-components'
export function LoadingState({ isLoading, children }) {
if (isLoading) {
return (
<View className="flex-1 items-center justify-center gap-3 p-8">
<Spinner size="large" />
<Text className="text-sm text-muted-foreground">Loading content...</Text>
</View>
)
}
return children
}Props API
SpinnerProps
Extends React.ComponentPropsWithoutRef<typeof ActivityIndicator> and includes:
| Prop | Type | Default | Description |
|---|---|---|---|
color | string | - | Override the spinner color. Defaults to the text-primary theme color |
size | 'small' | 'large' | 'small' | The size of the activity indicator (React Native built-in) |
className | string | - | Additional CSS classes for custom styling |
All standard React Native ActivityIndicator props are also supported.
Best Practices
-
Provide context: Pair Spinner with descriptive text so users know what is loading.
-
Appropriate sizing: Use
smallfor inline indicators (e.g., inside buttons) andlargefor full-screen or section loading states. -
Avoid blocking UI: Use Spinner for non-blocking loading states. For blocking operations, consider an overlay pattern.
-
Consistent placement: Center the spinner within its loading container for a polished look.
-
Accessibility: React Native's
ActivityIndicatoris automatically accessible to screen readers.
Related Components
- Use Spinner inside
Buttonwith theisLoadingprop for button loading states - Combine with
Skeletonfor content placeholder loading patterns - Pair with
Emptyfor loading-to-empty-state transitions