Components / Input controls
Auth Code Input
Component + managerRenders a 6-digit numeric code input, typically used for one-time passcodes or verification codes.
Live preview
Interactive exampleUsage
Import the component and its manager, then make it your own.
Component
AuthCodeInputManager
create_auth_code_input_manager<script>
// Import the shared stylesheet once in your application's root layout.
import "sveltekit-ui/style.css"
import { AuthCodeInput, create_auth_code_input_manager } from "sveltekit-ui"
let completed_code = $state("")
const manager = create_auth_code_input_manager({
name: "verification_code",
is_required: true,
on_sixth: (code) => { completed_code = code },
})
</script>
<label for={"auth_code_input_" + manager.id}>Six-digit verification code</label>
<AuthCodeInput {manager} />
{#if completed_code && manager.is_valid}<p role="status">Ready to verify {completed_code} with your server.</p>{/if}API reference
Configure the manager, call its methods, and read its reactive state.
14 entries in configuration
| Property | Type | Default | Description |
|---|---|---|---|
val | string | null | current 6-digit code value |
name | string | code | name attribute for the input |
is_required | boolean | false | marks the input as required if true |
is_read_only | boolean | false | makes the input read-only if true |
autocomplete | string | one-time-code | determines the browser’s autocomplete type |
is_valid | boolean | null | optionally control or reflect validation state |
is_disabled | boolean | false | disables the input if true |
border_radius | number | 1 | border radius for the input container in rem |
ml | number | 0 | margin-left in rem |
mr | number | 0 | margin-right in rem |
mt | number | 0 | margin-top in rem |
mb | number | 0 | margin-bottom in rem |
on_change | function | null | callback invoked when the input value changes, receives the cleaned value |
on_sixth | function | null | callback invoked when the input reaches 6 digits, receives the final code |