
Security News
CISA Kills Off RSS Feeds for KEVs and Cyber Alerts
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
react-time-ticker
Advanced tools
react-time-ticker is a customizable React countdown timer with smooth animations and flexible styling options. It integrates easily into projects and supports various configurations.
A customizable countdown timer component for React applications. The react-time-ticker
component displays a countdown timer with various units and styling options.
Before using this component, ensure that you have the following:
To install the TimeTicker
component, use npm or yarn:
npm install react-time-ticker
or
yarn add react-time-ticker
The most basic usage of the react-time-ticker
component involves providing an initialSeconds
prop for the countdown and an optional onTimesUp
callback.
import React from 'react';
import TimeTicker from 'react-time-ticker';
const App = () => (
<TimeTicker
initialSeconds={3600} // 1 hour countdown
onTimesUp={() => console.log('Time is up!')}
/>
);
export default App;
In this example, we will customize the appearance of the TimeTicker by passing customStyles, and only show hours, minutes, and seconds.
import React from 'react';
import TimeTicker from 'react-time-ticker';
const App = () => (
<TimeTicker
initialSeconds={7200} // 2 hours countdown
displayUnitsConfig={{
hours: true,
minutes: true,
seconds: true,
}}
customStyles={{
digitBg: '#222222',
digitColor: '#FFFFFF',
digitFontSize: '1.5rem',
labelColor: '#F1C40F',
labelFontSize: '0.875rem',
labelBg: '#333333',
separatorColor: '#E74C3C',
}}
labels={{
hours: 'Hours',
minutes: 'Minutes',
seconds: 'Seconds',
}}
emphasizeLabels={false}
isDoubleLine={true}
onTimesUp={() => alert('Countdown finished!')}
/>
);
export default App;
Name | Type | Default Value | Description |
---|---|---|---|
initialSeconds | number | 0 | The initial time in seconds. |
displayUnitsConfig | object | * | Configures which time units are displayed (years, months, days, etc.). |
onTimesUp | () => void | () => {} | Callback function that is called when the timer ends. |
customStyles | object | * | Custom styles object to override default styles (see the Styles section below). |
labels | object | * | Custom labels for each time unit (see the Labels section below). |
showLabels | boolean | true | Determines if labels should be shown. |
emphasizeLabels | boolean | true | Determines if labels should be emphasized. |
isDoubleLine | boolean | false | Determines if the display should be in double-line mode. |
customStyles
(Styles Object)The customStyles
prop is an object that allows you to define specific styles for the timer. You can override the default styles by providing values for the following properties:
Property | Type | Default Value | Description |
---|---|---|---|
labelBg | string | #1f2937 | Background color for labels. |
labelColor | string | #f9fafb | Text color for labels. |
labelFontSize | string | 0.6875rem | Font size for labels. |
labelPaddingY | string | 0.3rem | Vertical padding for labels. |
fontFamily | string | sans-serif | Font family for the component. |
separatorColor | string | #1f2937 | Color for separators. |
verticalSeparatorColor | string | #1f2937 | Color for vertical separators. |
digitBg | string | #1f2937 | Background color for digits. |
digitColor | string | #f9fafb | Text color for digits. |
digitFontSize | string | 0.875rem | Font size for digits. |
digitWidth | string | 1.75rem | Width of each digit. |
digitHeight | string | 2rem | Height of each digit. |
displayUnitsConfig
(Units Object)Property | Type | Default | Description |
---|---|---|---|
years | boolean | true | Show the years unit in the ticker. |
months | boolean | true | Show the months unit in the ticker. |
days | boolean | true | Show the days unit in the ticker. |
hours | boolean | true | Show the hours unit in the ticker. |
minutes | boolean | true | Show the minutes unit in the ticker. |
seconds | boolean | true | Show the seconds unit in the ticker. |
labels
(Labels Object)The labels
prop is an object that allows you to provide custom labels for each time unit. The object can include the following properties:
Property | Type | Description |
---|---|---|
years | string | Label for the "years" unit. |
months | string | Label for the "months" unit. |
days | string | Label for the "days" unit. |
hours | string | Label for the "hours" unit. |
minutes | string | Label for the "minutes" unit. |
seconds | string | Label for the "seconds" unit. |
You can pass a custom function using the onTimesUp
prop, which is triggered when the countdown reaches zero. This allows you to implement any custom logic, such as redirecting the user, showing a message, or starting a new countdown.
<TimeTicker
initialSeconds={1800} // 30 minutes
onTimesUp={() => {
console.log('Countdown finished!');
// Custom behavior here
}}
/>
You can view a live demo of the React Time Ticker component here.
TimeTicker
component with core features:
onTimesUp
callback function.Feel free to open issues and submit pull requests on GitHub.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
react-time-ticker is a customizable React countdown timer with smooth animations and flexible styling options. It integrates easily into projects and supports various configurations.
The npm package react-time-ticker receives a total of 4 weekly downloads. As such, react-time-ticker popularity was classified as not popular.
We found that react-time-ticker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.