Convert Figma logo to code with AI

bartgryszko logoreact-native-circular-progress

React Native component for creating animated, circular progress with ReactART

2,156
425
2,156
75

Top Related Projects

Progress indicators and spinners for React Native

React Native Calendar Components 🗓️ 📆

SVG library for React Native, React Native Web, and plain React web projects.

React Native Mapview component for iOS + Android

Cross-Platform React Native UI Toolkit

Quick Overview

The react-native-circular-progress library is a React Native component that allows you to create circular progress indicators with customizable appearance and behavior. It provides a simple and flexible API for adding circular progress indicators to your React Native applications.

Pros

  • Customizable Appearance: The library offers a wide range of customization options, allowing you to adjust the size, color, and animation of the progress indicator to match the design of your application.
  • Flexible API: The API is straightforward and easy to use, making it simple to integrate the progress indicator into your React Native components.
  • Cross-Platform Compatibility: The library works seamlessly on both iOS and Android platforms, ensuring a consistent user experience across different devices.
  • Active Maintenance: The project is actively maintained, with regular updates and bug fixes, ensuring its continued reliability and compatibility with the latest versions of React Native.

Cons

  • Limited Functionality: The library is focused solely on creating circular progress indicators, and may not provide the full range of progress indicator types or features that some developers might require.
  • Dependency on React Native: As a React Native-specific library, react-native-circular-progress is not directly usable in web-based React applications, which may limit its broader applicability.
  • Potential Performance Issues: Depending on the complexity of your progress indicator and the number of instances in your application, the library's performance may be a concern, especially on lower-end devices.
  • Limited Documentation: While the library's API is relatively straightforward, the documentation could be more comprehensive, making it potentially more challenging for new users to get started.

Code Examples

Here are a few examples of how to use the react-native-circular-progress library in your React Native application:

import React from 'react';
import { View } from 'react-native';
import { CircularProgress } from 'react-native-circular-progress';

const ProgressIndicator = () => {
  return (
    <View>
      <CircularProgress
        value={75}
        radius={50}
        fill="#00e0ff"
        tintColor="#3498db"
        backgroundColor="#3e3e3e"
      />
    </View>
  );
};

export default ProgressIndicator;

This example creates a simple circular progress indicator with a value of 75%, a radius of 50, and customized colors.

import React, { useState, useEffect } from 'react';
import { View, StyleSheet } from 'react-native';
import { CircularProgress } from 'react-native-circular-progress';

const AnimatedProgressIndicator = () => {
  const [progress, setProgress] = useState(0);

  useEffect(() => {
    const interval = setInterval(() => {
      setProgress((prevProgress) => (prevProgress + 5) % 100);
    }, 500);

    return () => clearInterval(interval);
  }, []);

  return (
    <View style={styles.container}>
      <CircularProgress
        value={progress}
        radius={100}
        duration={500}
        arcSweepAngle={360}
        rotation={0}
        lineCap="round"
        fillColor="#2980b9"
        backgroundColor="#ecf0f1"
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

export default AnimatedProgressIndicator;

This example creates an animated circular progress indicator that updates every 500 milliseconds, cycling through the full 360-degree range.

import React from 'react';
import { View, Text } from 'react-native';
import { CircularProgress } from 'react-native-circular-progress';

const ProgressWithText = () => {
  return (
    <View>
      <CircularProgress
        value={75}
        radius={50}
        fill="#00e0ff"
        tintColor="#3498db"
        backgroundColor="#3e3e3e"
        renderChildren={(value) => (
          <Text style={{ fontSize: 24, fontWeight: 'bold'

Competitor Comparisons

Progress indicators and spinners for React Native

Pros of react-native-progress

  • Offers a wider variety of progress indicators (circle, bar, pie)
  • Provides more customization options for each progress type
  • Has better TypeScript support and type definitions

Cons of react-native-progress

  • Slightly larger package size due to more features
  • May have a steeper learning curve for beginners due to more options

Code Comparison

react-native-circular-progress:

<AnimatedCircularProgress
  size={120}
  width={15}
  fill={75}
  tintColor="#00e0ff"
  backgroundColor="#3d5875"
/>

react-native-progress:

<Progress.Circle
  size={120}
  progress={0.75}
  thickness={15}
  color="#00e0ff"
  unfilledColor="#3d5875"
/>

Both libraries offer similar functionality for circular progress, but react-native-progress provides more options for customization and different types of progress indicators. The syntax is slightly different, with react-native-circular-progress using the fill prop for progress, while react-native-progress uses the progress prop.

react-native-progress is more versatile and feature-rich, making it suitable for projects requiring various progress indicators. However, if you only need circular progress, react-native-circular-progress might be a simpler, more lightweight option.

React Native Calendar Components 🗓️ 📆

Pros of react-native-calendars

  • More comprehensive calendar functionality, including various calendar types and customization options
  • Actively maintained with regular updates and a larger community
  • Extensive documentation and examples for easier implementation

Cons of react-native-calendars

  • Larger package size due to more features, potentially impacting app performance
  • Steeper learning curve for basic calendar implementations
  • May require more setup and configuration for simple use cases

Code Comparison

react-native-calendars:

import {Calendar} from 'react-native-calendars';

<Calendar
  markedDates={{
    '2023-05-16': {selected: true, marked: true, selectedColor: 'blue'},
    '2023-05-17': {marked: true},
    '2023-05-18': {marked: true, dotColor: 'red', activeOpacity: 0}
  }}
/>

react-native-circular-progress:

import {CircularProgress} from 'react-native-circular-progress';

<CircularProgress
  size={120}
  width={15}
  fill={75}
  tintColor="#00e0ff"
  backgroundColor="#3d5875"
/>

The code comparison shows that react-native-calendars is focused on date-related functionality, while react-native-circular-progress is designed for displaying progress in a circular format. The APIs differ significantly due to their distinct purposes.

SVG library for React Native, React Native Web, and plain React web projects.

Pros of react-native-svg

  • More comprehensive SVG support, allowing for complex vector graphics
  • Highly customizable with a wide range of SVG elements and attributes
  • Actively maintained with frequent updates and improvements

Cons of react-native-svg

  • Steeper learning curve due to its extensive feature set
  • Potentially larger bundle size if only basic circular progress is needed
  • May require more setup and configuration for simple use cases

Code Comparison

react-native-circular-progress:

<AnimatedCircularProgress
  size={120}
  width={15}
  fill={75}
  tintColor="#00e0ff"
  backgroundColor="#3d5875"
/>

react-native-svg:

<Svg height="120" width="120">
  <Circle
    cx="60"
    cy="60"
    r="52.5"
    stroke="#3d5875"
    strokeWidth="15"
    fill="none"
  />
  <Circle
    cx="60"
    cy="60"
    r="52.5"
    stroke="#00e0ff"
    strokeWidth="15"
    fill="none"
    strokeDasharray={330}
    strokeDashoffset={82.5}
  />
</Svg>

react-native-circular-progress is more straightforward for creating circular progress indicators, while react-native-svg offers greater flexibility but requires more manual implementation for similar results.

React Native Mapview component for iOS + Android

Pros of react-native-maps

  • Comprehensive mapping solution with support for various map providers
  • Rich set of features including markers, polygons, and custom overlays
  • Large community and extensive documentation

Cons of react-native-maps

  • Larger package size and potential performance impact
  • More complex setup and configuration process
  • Steeper learning curve for basic map implementations

Code Comparison

react-native-maps:

import MapView, { Marker } from 'react-native-maps';

<MapView
  initialRegion={{
    latitude: 37.78825,
    longitude: -122.4324,
    latitudeDelta: 0.0922,
    longitudeDelta: 0.0421,
  }}
>
  <Marker coordinate={{ latitude: 37.78825, longitude: -122.4324 }} />
</MapView>

react-native-circular-progress:

import { AnimatedCircularProgress } from 'react-native-circular-progress';

<AnimatedCircularProgress
  size={120}
  width={15}
  fill={75}
  tintColor="#00e0ff"
  backgroundColor="#3d5875"
/>

While react-native-maps offers a full-featured mapping solution, react-native-circular-progress provides a simpler, focused component for displaying circular progress. The choice between them depends on the specific requirements of your project, with react-native-maps being more suitable for location-based applications and react-native-circular-progress for visual progress indicators.

Cross-Platform React Native UI Toolkit

Pros of react-native-elements

  • Comprehensive UI toolkit with a wide range of pre-built components
  • Highly customizable and themeable components
  • Active community and regular updates

Cons of react-native-elements

  • Larger package size due to the extensive component library
  • May require additional configuration for specific use cases
  • Learning curve for utilizing all features and customization options

Code Comparison

react-native-elements:

import { Button } from 'react-native-elements';

<Button
  title="Click me"
  buttonStyle={{ backgroundColor: 'blue' }}
  onPress={() => console.log('Button pressed')}
/>

react-native-circular-progress:

import { CircularProgress } from 'react-native-circular-progress';

<CircularProgress
  size={120}
  width={15}
  fill={75}
  tintColor="#00e0ff"
  backgroundColor="#3d5875"
/>

Summary

react-native-elements is a comprehensive UI toolkit offering a wide range of customizable components, making it suitable for various app development needs. It benefits from an active community and regular updates. However, its extensive library may lead to a larger package size and a steeper learning curve.

react-native-circular-progress, on the other hand, is a focused library specifically for creating circular progress indicators. It's lightweight and easy to implement for its specific use case but lacks the versatility of a full UI toolkit.

Choose react-native-elements for a complete UI solution, or react-native-circular-progress for a specialized circular progress component with minimal overhead.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

react-native-circular-progress

license Version npm

React Native component for creating animated, circular progress. Useful for displaying users points for example.

Example app

image

Installation

  1. Install this component and react-native-svg:

    npm i --save react-native-circular-progress react-native-svg

  2. Link native code for SVG:

    react-native link react-native-svg

Usage

import { AnimatedCircularProgress } from 'react-native-circular-progress';

<AnimatedCircularProgress
  size={120}
  width={15}
  fill={100}
  tintColor="#00e0ff"
  onAnimationComplete={() => console.log('onAnimationComplete')}
  backgroundColor="#3d5875" />

You can also define a function that'll receive current progress and for example display it inside the circle:

<AnimatedCircularProgress
  size={200}
  width={3}
  fill={this.state.fill}
  tintColor="#00e0ff"
  backgroundColor="#3d5875">
  {
    (fill) => (
      <Text>
        { this.state.fill }
      </Text>
    )
  }
</AnimatedCircularProgress>

You can also define a function that'll receive the location at the top of the progress circle and render a custom SVG element:

<AnimatedCircularProgress
  size={120}
  width={15}
  fill={100}
  tintColor="#00e0ff"
  backgroundColor="#3d5875"
  padding={10}
  renderCap={({ center }) => <Circle cx={center.x} cy={center.y} r="10" fill="blue" />}
  />

Finally, you can manually trigger a duration-based timing animation by putting a ref on the component and calling the animate(toValue, duration, easing) function like so:

<AnimatedCircularProgress
  ref={(ref) => this.circularProgress = ref}
  ...
/>
this.circularProgress.animate(100, 8000, Easing.quad); // Will fill the progress bar linearly in 8 seconds

The animate-function returns the timing animation so you can chain, run in parallel etc.

Configuration

You can configure the CircularProgress-component by passing the following props:

NameTypeDefault valueDescription
sizenumber|Animated.ValuerequiredWidth and height of circle
widthnumberrequiredThickness of the progress line
backgroundWidthnumberwidthThickness of background circle
fillnumber (0-100)0Current progress / fill
tintColorstringblackColor of the progress line
tintTransparencybooleantrueTransparency of the progress line
backgroundColorstringIf unspecified, no background line will be rendered
rotationnumber (-360 - 360)90Angle from which the progress starts from
lineCapstringbuttShape used at ends of progress line. Possible values: butt, round, square
arcSweepAnglenumber (0-360)360If you don't want a full circle, specify the arc angle
styleViewPropTypes.styleExtra styling for the main container
childrenfunctionPass a function as a child. It received the current fill-value as an argument
childrenContainerStyleViewPropTypes.styleExtra styling for the children container
paddingnumber0Padding applied around the circle to allow for a cap that bleeds outside its boundary
dashedBackgroundobject{ width: 0, gap: 0 }Bar background as dashed type
dashedTintobject{ width: 0, gap: 0 }Bar tint as dashed type
renderCapfunctionundefinedFunction that's invoked during rendering to draw at the tip of the progress circle

The following props can further be used on AnimatedCircularProgress:

NameTypeDefault valueDescription
prefillnumber (0-100)0Initial fill-value before animation starts
durationnumber500Duration of animation in ms
delaynumber0Delay of animation in ms
easingfunctionEasing.out(Easing.ease)Animation easing function
onAnimationCompletefunctionFunction that's invoked when the animation completes (both on mount and if called with .animate())
onFillChangefunctionFunction that returns current progress on every change
tintColorSecondarystringthe same as tintColorTo change fill color from tintColor to tintColorSecondary as animation progresses

AnimatedCircularProgress also exposes the following functions:

NameArgumentsDescription
animate(toVal: number, duration: number, ease: function)Animate the progress bar to a specific value
reAnimate(prefill: number, toVal: number, duration: number, ease: function)Re-run animation with a specified prefill-value

Running example app (Expo)

git clone https://github.com/bgryszko/react-native-circular-progress.git
cd react-native-circular-progress/example-app
yarn
yarn start

Authors

  • Bartosz Gryszko (b@gryszko.com)
  • Markus Lindqvist
  • Jacob Lauritzen
  • Special thanks to all contributors!

License

MIT

Special thanks

Special thanks to Chalk+Chisel for creating working environment where people grow. This component was created for one of the projects we're working on.

NPM DownloadsLast 30 Days