Skip to main content

Crate otprs

Crate otprs 

Source
Expand description

Β§πŸ” OTP RS

Crates.io Crates.io Downloads Crates.io License made-with-rust Rust Maintenance

Open SASS Discord

logo

§🎬 Demo

FrameworkLive Demo
YewNetlify Status
DioxusNetlify Status
LeptosNetlify Status

Β§πŸ“œ Intro

A highly customizable, accessible OTP (One-Time Password) input component for WASM frameworks: Yew, Dioxus, and Leptos.

Supports animated per-slot digit entry with automatic focus traversal, primary and secondary visual variants, built-in HOTP/TOTP validation per RFC 4226 and RFC 6238, and full WCAG compliance.

Β§πŸ€” Why OTP RS?

  1. 🎨 Fully Customizable: Control every attribute, class, style, variant, pattern, ARIA labels and more, on the outermost container, each group, each slot, and each separator.
  2. ⌨ Smart Focus Management: Typing a digit automatically advances focus. Backspace regresses focus. Arrow keys navigate left and right.
  3. ✨ Animated Entry: Each digit pops with a scale animation when entered, and a blinking caret is shown in the active empty slot.
  4. πŸ” Built-in Validation: Validate against HOTP (RFC 4226) or TOTP (RFC 6238) using a pure-Rust implementation, no C, no external crypto crates.
  5. β™Ώ Accessible by Default: role="group", aria-label, inputmode, autocomplete="one-time-code", disabled/invalid data-attributes all wired up automatically.
  6. 🧩 Framework Agnostic: Same API semantics across Yew, Dioxus, and Leptos.

Β§Y Yew Usage

Refer to our guide to integrate this component into your Yew app.

§🧬 Dioxus Usage

Refer to our guide to integrate this component into your Dioxus app.

§🌱 Leptos Usage

Refer to our guide to integrate this component into your Leptos app.

§🀝 Contributions

Contributions are welcome! Whether it’s bug fixes, feature requests, or examples, we would love your help to make OTP RS better.

  1. Fork the repository.
  2. Create a new branch for your feature/bugfix.
  3. Submit a pull request for review.

Β§πŸ“œ License

OTP RS is licensed under the MIT License. You are free to use, modify, and distribute this library in your projects.

Re-exportsΒ§

pub use common::InputMode;
pub use common::OtpValidationError;
pub use common::Variant;
pub use common::generate_totp;
pub use common::hotp;
pub use common::pattern;
pub use common::validate_hotp;
pub use common::validate_totp;
pub use common::unix_now_secs;dio or lep or yew

ModulesΒ§

common
dioxusdio
🧬 OTP RS Dioxus Usage
leptoslep
🌱 OTP RS Leptos Usage
yewyew
Y OTP RS Yew Usage