Timer
A pure vanilla JS implementation of Zag JS Timer
Anatomy
The Timer component consists of the following data-part
root
area
item
separator
control
action-trigger
Data attributes
Each timer can be set with different settings with the following data-attribute.
Callbacks
Each Timer component can receive callbacks that can be used to respond to user interaction with custom behavior.
You must add a custom id for the timer and a event listener for your event name
document.getElementById("my-callback-timer")
?.addEventListener("my-callback-timer-event", (event) => {
console.log("Received event:", (event as CustomEvent).detail);
});
Open your browser's console to see the events received when the timer is copied
Custom (Tailwind)
If you are using Tailwind styling, you can customize each timer and its parts with Tailwind utilities
Templates
Timer components is available in the followng templates
-
Corex template
Default corex templates. It provides the global, semantic and components tokens
-
Modex template
Based on Corex default template, it adds dark and light mode option to the tokens
-
Themex template
Based on the Corex default template, it adds theming capabilities as well as light and dark mode options to the tokens.