Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

React Native Countdown Component

A customizable countdown component for React Native applications. This component provides a flexible and customizable countdown timer with support for days, hours, minutes, and seconds.

Preview

Basic Countdown

Basic Countdown Example

Custom Styled Countdown

Custom Countdown Example

Features

  • Customizable time units (Days, Hours, Minutes, Seconds)
  • Configurable digit and label styles
  • Support for separators between time units
  • Background state handling
  • TypeScript support
  • Flexible styling options

Installation

# Using npm
npm install react-native-countdown-eggmun
# Using yarn
yarn add react-native-countdown-eggmun

Usage

importReactfrom'react';import{View}from'react-native';importCountDownfrom'react-native-countdown-eggmun';constApp=()=>{return(<View><CountDownuntil={3600}// secondsonFinish={()=>console.log('Countdown finished!')}size={20}timeToShow={['H','M','S']}timeLabels={{h: 'Hours',m: 'Minutes',s: 'Seconds'}}/></View>);};

Props

PropTypeDefaultDescription
untilnumberrequiredNumber of seconds to count down
onChange(until: number) => void-Callback when countdown changes
onFinish() => void-Callback when countdown finishes
onPress() => void-Callback when countdown is pressed
runningbooleantrueWhether the countdown is running
sizenumber15Size of the digits
digitStyleobject{ backgroundColor: '#FAB913' }Style for the digit container
digitTxtStyleobject{ color: '#000' }Style for the digit text
timeLabelStyleobject{ color: '#000' }Style for the time labels
separatorStyleobject{ color: '#000' }Style for the separator
timeToShowstring[]['D', 'H', 'M', 'S']Which time units to show
showSeparatorbooleanfalseWhether to show separators between time units
timeLabelsobject{ d: 'Days', h: 'Hours', m: 'Minutes', s: 'Seconds' }Labels for time units

Complete Example

importReactfrom'react';import{View,StyleSheet}from'react-native';importCountDownfrom'react-native-countdown-eggmun';constExample=()=>{return(<Viewstyle={styles.container}><CountDownuntil={86400}// 24 hourssize={25}timeToShow={['D','H','M','S']}timeLabels={{d: 'Days',h: 'Hours',m: 'Minutes',s: 'Seconds'}}digitStyle={{backgroundColor: '#1B5E20'}}digitTxtStyle={{color: '#fff'}}timeLabelStyle={{color: '#1B5E20'}}separatorStyle={{color: '#1B5E20'}}showSeparatoronFinish={()=>console.log('Countdown finished!')}style={styles.countdown}/></View>);};conststyles=StyleSheet.create({container: {flex: 1,justifyContent: 'center',alignItems: 'center',backgroundColor: '#fff',},countdown: {padding: 20,},});exportdefaultExample;

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages