Activity Indicator

Let's people know that your app isn't stalled while it loads content or performs lengthy operations.

Apple
Apple
import { Icon } from '@roninoss/icons';
import { Stack } from 'expo-router';
import { View, Text, ScrollView, Pressable } from 'react-native';

import { ActivityIndicator } from '~/components/nativewindui/ActivityIndicator';
import { useColorScheme } from '~/lib/useColorScheme';

export default function ActivityIndicatorScreen() {
  const { colors } = useColorScheme();
  return (
    <>
      <Stack.Screen
        options={{
          title: 'NativeWindUI',
          headerSearchBarOptions: {
            hideWhenScrolling: false,
          },
          headerLargeTitle: true,
          headerRight() {
            return (
              <Pressable className="opacity-80 active:opacity-40">
                <View className="opacity-90">
                  <Icon name="cog-outline" color={colors.foreground} />
                </View>
              </Pressable>
            );
          },
        }}
      />
      <ScrollView contentInsetAdjustmentBehavior="automatic" className="p-4">
        <View className="border-border bg-card gap-4 rounded-xl border p-4 pb-6 shadow-sm shadow-black/10 dark:shadow-none">
          <Text className="text-foreground text-center text-sm font-medium tracking-wider opacity-60">
            Activity Indicator
          </Text>
          <View className="p-4">
            <ActivityIndicator />
          </View>
        </View>
      </ScrollView>
    </>
  );
}

Installation

1

Run the following command:

npx nwui-cli@latest add activity-indicator
🚀
Ship.
1

Copy/paste the following code to the specified file path:

~/components/nativewindui/ActivityIndicator.tsx
import { ActivityIndicator as RNActivityIndicator } from 'react-native';

import { useColorScheme } from '~/lib/useColorScheme';

function ActivityIndicator(props: React.ComponentPropsWithoutRef<typeof RNActivityIndicator>) {
  const { colors } = useColorScheme();
  return <RNActivityIndicator color={colors.primary} {...props} />;
}

export { ActivityIndicator };
🛸
Ship.

Usage

import { ActivityIndicator } from '~/components/nativewindui/ActivityIndicator';
<ActivityIndicator />

Props

Inherits all the props from React Native's Activity Indicator component.

© Ronin Technologies LLC 2024