Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

React Native button component with multiple animated spinners

License

NotificationsYou must be signed in to change notification settings

SimformSolutionsPvtLtd/react-native-spinner-button

Repository files navigation

Tree-Selection

react-native-spinner-buttonnpm versionAndroidiOSMIT

React Native Spinner Button component library provides dynamic spinner buttons and ripple effects, enriching the user experience with smooth animations and intuitive feedback

Library is compatible with both Android and iOS platforms, offering a versatile solution to elevate your app's user interface with ease.

🎬 Preview

Example of react-native-spinner-button

Quick Access

Installation |Usage and Examples |Properties |Example Code |License

Getting Started

Here's how to get started with react-native-spinner-button in your React Native project:

Installation

1. Install the package

npm install react-native-spinner-button react-native-gradients react-native-svg

UsingYarn:

yarn add react-native-spinner-button react-native-gradients react-native-svg
2. Install cocoapods in the ios project
cd ios&& pod install

Usage

importReact,{useState,useCallback}from'react';import{StyleSheet,Text,View}from'react-native';importSpinnerButtonfrom'react-native-spinner-button';constApp:React.FC=()=>{const[isLoading,setLoading]=useState<boolean>(false);consthandleButtonPress=useCallback<()=>void>(()=>{setLoading(true);setTimeout(()=>{setLoading(false);},3000);},[]);return(<Viewstyle={styles.screen}>{/* Your button component */}<SpinnerButtonbuttonStyle={styles.buttonStyle}isLoading={isLoading}onPress={()=>{handleButtonPress();}}indicatorCount={10}><Textstyle={styles.buttonText}>Default Or Ball SpinnerButton</Text></SpinnerButton></View>);};exportdefaultApp;conststyles=StyleSheet.create({screen:{flex:1,justifyContent:'center',alignItems:'center',},buttonStyle:{borderRadius:10,margin:10,backgroundColor:'#893346',},buttonText:{fontSize:20,textAlign:'center',color:'white',},});

Example of Ripple Effect Button

importReactfrom'react';import{StyleSheet,Text,View}from'react-native';importSpinnerButtonfrom'react-native-spinner-button';constApp:React.FC=()=>{constbuttonPress:()=>void=()=>{console.log('Button Clicked');};return(<Viewstyle={styles.screen}><SpinnerButtonanimationType="ripple-effect"onPress={buttonPress}buttonStyle={styles.btnStyle}animatedDuration={400}><Textstyle={styles.textStyle}>RippleButton</Text></SpinnerButton></View>);};conststyles=StyleSheet.create({screen:{flex:1,justifyContent:'center',},btnStyle:{margin:10,backgroundColor:'#893346',},textStyle:{fontSize:20,textAlign:'center',color:'white',},});exportdefaultApp;

🎬 Preview

Spinner ButtonRipple Button
alt Defaultalt Modal

Properties

Props for the spinner button

PropsDefaultTypeDescription
onPress-functionThe function to execute upon tapping the button
animationTypenull or undefinedstringType of animation for the button and spinner, For more details about properties, referreact-native-animatable and also support "ripple-effect"
buttonStyle{height: 50}array or objectButton styling
borderStyle-array or objectIt's a stylesheet object supporting all basic border properties like width, radius, color, and style (solid, dotted, and dashed), etc
spinnerColorwhitestringThe color of the spinner
spinnerTypeBallIndicatorstringType of the spinner: BallIndicator, BarIndicator, DotIndicator, MaterialIndicator, PacmanIndicator, PulseIndicator, SkypeIndicator, UIActivityIndicator, WaveIndicator.
isLoadingfalsebooleanThe flag to render a button or a spinner. false will render a button, and true will render a spinner
indicatorCount8numberThe count property of react-native-indicators
size16numberThe size of the dot in DotIndicator
spinnerOptions-objectAn object of waveMode for WaveIndicator. For more details about these properties, referreact-native-indicators
gradientType-stringGradients allow you to display more than one color with a smooth transition between the colors (think Instagram logo). Currently, we support two types of gradients: linear and radial
gradientColors-arrayColors can be passed in different formats such as name, RGBA, hex, etc. The colors should be ordered in the way we want them to be displayed. For example, colors={[ "purple", "white" ]}, the gradient will transition from purple to white
gradientColoroffset-arrayAn array of strings that defines where each color will stop in the gradient. These values are passed as a percentage of the entire gradient from 0% to 100% and must correspond to the colors passed in length and position. For example, with colors={[“red”, “yellow”, “green”]}, then we’ll have locations={['0%', '50%', '80%']}, with the first color (red) covering '0%' – '50%', the second (yellow) going from '50%' – '80%', and the third (green) from '80%' – '100%'
gradientColorAngle-numberThe gradient line's angle of direction. A value of 0deg is equivalent to the top; increasing values rotate clockwise from there. The angle range is from 0 to 360 degreesMore detail to read
gradientRadialRadius-numberThis property is used for radial type gradients to set the radius of the radial gradient
gradientButtonHeight-numberThe size of the gradient component
radialRadiusx-string or numberThe x-coordinate of the center of the radial gradient
radialRadiusy-string or numberThe y-coordinate of the center of the radial gradient
radialRadiusRX-string or numberThe horizontal radius of the radial gradient defining the ellipse
radialRadiusRY-string or numberThe vertical radius of the radial gradient defining the ellipse
animatedDuration300numberThis property is used to define the duration of the animation, indicating how long it will take to execute the animation
customSpinnerComponent-nodeThis prop allows you to add your own custom spinner component
animateWidth-numberThis prop is used to set the component width when the progress/loading starts. If you do not set this prop, it will identify the width and height which are minimum and then use that value
animateHeight-numberThis prop is used to set the component height when the progress/loading starts. If you do not set this prop, it will identify the width and height which are minimum and then use that value
animateRadius-numberThis prop is used to set the component radius when the progress/loading starts. If you do not set this prop, it will create a circle shape by default
isConnectedtruebooleanThe flag is used to identify the network connection, and based on the flag, the user iteration is set. false will render the button in disabled mode, and true will render the button in normal mode
disabledfalsebooleanThe flag to identify button enable/disable. true will render the button in disabled mode, and false will render the button in normal mode
disableStyle-array or objectIt's a stylesheet object. This style applies when identifying the button as disabled or if network connection is not available
gradientName-stringThese properties are used whenever you want to use a gradient but do not pass the gradientColors, gradientColorOffset, and gradientColorAngle properties
disableGradientColors-arrayColors can be passed in different formats such as names, RGBA, hex, etc. The colors should be ordered in the way we want them to be displayed. For example, with colors={[ "purple", "white" ]}, the gradient will transition from purple to white
rippleColorrgba(255, 255, 255, .25)stringColor of the ripple animation effect

Example

A full working example project is hereExample

yarnyarn example ios   // For iosyarn example android   // For Android

Find this library useful? ❤️

Support it by joiningstargazers for this repository.⭐

Bugs / Feature requests / Feedbacks

For bugs, feature requests, and discussion please useGitHub Issues,GitHub New Feature,GitHub Feedback

🤝 How to Contribute

We'd love to have you improve this library or fix a problem 💪Check out ourContributing Guide for ideas on contributing.

Awesome Mobile Libraries

License


[8]ページ先頭

©2009-2025 Movatter.jp