lotusui the ikaito design language for Gio — desktop, mobile, web
GitHub

InputOTP

The one-time-code input: attached character slots, one hidden editor.

Click anywhere on the row, type or paste — the code fills left to right, and the active slot carries the focus ring. One editor drives every slot, so paste and backspace behave exactly like a text field.

Installation

Use the module import (the default), or own the source: lotusui add vendors the component into your app and lotusui update keeps the copy mergeable — see Registry.

Go
go get github.com/ikaito-com/lotusui

# or vendor the source into your app:
go run github.com/ikaito-com/lotusui/cmd/lotusui add input-otp

Usage

Go
var code lotusui.InputOTP // six slots by default

code.Layout(th, gtx)
value := code.Value()

Separator

Groups splits the slots with a dash between groups.

Go
code := lotusui.InputOTP{Groups: []int{2, 2, 2}}

Length

Go
code := lotusui.InputOTP{Length: 4}

Pattern

Filter is the allow-list — digits only for numeric codes.

Go
code := lotusui.InputOTP{Filter: "0123456789"}

Disabled

Go
code.Disabled = true

Invalid

Invalid renders danger borders; pair it with a Field error.

Go
code.Invalid = true

API

OptionTypeDescription
LengthintSlot count; zero means 6.
Groups[]intSlots per group, a dash between groups.
FilterstringAllow-list; empty accepts everything.
Disabled / InvalidboolDimmed and inert; danger borders.
Value() / SetValue(s)methodThe code typed so far.

Every demo on this site is the real Go component compiled to WebAssembly — one gallery app, one bundle, addressed by URL hash.