# Input OTP Component API A one-time password input with individual digit fields. --- ## Installation ```toml # Cargo.toml [dependencies] shadcn-ui-leptos-input-otp = "0.7" ``` ```rust use shadcn_ui_leptos_input_otp::InputOtp; ``` --- ## Component API ### InputOtp | Prop | Type | Default | Description | |------|------|---------|-------------| | `value` | `Signal` | **Required** | Current OTP value | | `on_change` | `Option>` | `None` | Change handler | | `length` | `MaybeProp` | `6` | Number of digits | | `disabled` | `Signal` | `false` | Disable input | --- ## Usage Examples ### Basic OTP Input ```rust use leptos::prelude::*; use shadcn_ui_leptos_input_otp::InputOtp; #[component] pub fn MyComponent() -> impl IntoView { let (otp, set_otp) = signal(String::new()); view! {

{format!("Entered: {}", otp.get())}

} } ``` --- ## CSS Classes ```css .input-otp { flex gap-2 } .input-otp-slot { flex h-10 w-10 items-center justify-center rounded-md border border-input bg-background text-center text-sm ring-offset-background transition-all focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 } ``` --- ## Accessibility ### Keyboard Navigation | Key | Action | |-----|--------| | **Digit** | Enter digit, move to next | | **Backspace** | Delete, move to previous | | **Arrow Keys** | Navigate slots | | **Paste** | Fill all slots | --- ## TypeScript API ```typescript interface InputOtpProps { value: string; onChange?: (value: string) => void; length?: number; disabled?: boolean; } export const InputOtp: React.FC; ``` --- *Source: [packages/leptos/input-otp/src/default.rs](https://github.com/yourusername/leptos-shadcn-ui/blob/main/packages/leptos/input-otp/src/default.rs)*