Expand description
§dioxus-nox-timer
⚠️ Disclaimer: This crate was entirely generated by AI (Claude) as part of a personal learning project. It has not been battle-tested in production and may contain bugs or unsound abstractions. Use at your own risk and exercise extreme caution before depending on it in anything that matters.
Headless timer primitives for Dioxus applications: countdown and stopwatch hooks.
§Features
- Wall-clock based — survives browser tab backgrounding (no
setIntervaldrift) - Cross-platform — works on web (wasm32), desktop, iOS, and Android
- Headless — no rendered components, just hooks and state machines
§Quick start
ⓘ
use dioxus::prelude::*;
use dioxus_nox_timer::*;
#[component]
fn RestTimer() -> Element {
let (remaining, state, controls) = use_countdown(None);
rsx! {
div {
// Recommended ARIA attributes for consumers:
role: "timer",
aria_live: "polite",
"data-timer-state": match *state.read() {
TimerState::Idle => "idle",
TimerState::Running => "running",
TimerState::Paused => "paused",
TimerState::Complete => "complete",
},
p { "{format_duration(*remaining.read())}" }
button { onclick: move |_| controls.start.call(90), "Start 90s" }
button { onclick: move |_| controls.pause.call(()), "Pause" }
button { onclick: move |_| controls.resume.call(()), "Resume" }
}
}
}Structs§
- Countdown
Controls - Controls returned by
use_countdown.
Enums§
- Timer
State - Timer state machine.
Functions§
- format_
duration - Format seconds as
M:SSorH:MM:SS. - use_
countdown - Countdown timer hook.
- use_
stopwatch - Stopwatch hook — counts up from a start time.