PinInput

分格输入验证码或短文本。

实时预览

正在加载预览…

参数配置

全部字段 16

PinInputOptions

列表项 · 0
Styles · 0

Go 代码

Go
// Inside a view; c is *ui.Context, t is nui.Theme.
// Keep s (example state) outside the view. See the complete example.
nui.PinInput(c.Key("pin"), t, &s.Value, &s.Pin, nui.PinInputOptions{Label: "Verification code", Length: 6, Numeric: true, Mask: false, ReadOnly: false, Disabled: false, Color: nui.ColorDefault, Size: nui.SizeDefault, Variant: nui.VariantDefault})

使用说明

按格输入验证码,比较长度、数字限制与遮蔽显示。PinInputState 保留编辑位置;示例仅演示输入,不发送短信或验证身份。

API 参考

PinInput

源码
func PinInput(c *ui.Context, t Theme, value *string, s *PinState, o PinInputOptions) ui.Element

PinInputOptions

源码
type PinInputOptions struct {
	Label                string
	Length               int
	Disabled, Mask       bool
	Numeric, ReadOnly    bool // Text is the default; Numeric keeps only ASCII digits.
	Placeholder          string
	Color                Color
	Variant              Variant
	Size                 Size
	Separator            []int // Insert a separator after these 1-based slots.
	SeparatorEvery       int   // Insert after every N slots; Separator also applies.
	OnChange, OnComplete func(string)
	Decoration
}
字段类型说明
Labelstring

Go 零值: ""

控件标签或可访问名称。

Lengthint

Go 零值: 0

验证码输入格数。

Disabledbool

Go 零值: false

禁用组件及其交互。

Maskbool

Go 零值: false

遮蔽验证码字符。

Numericbool

Go 零值: false

仅允许数字字符。

ReadOnlybool

Go 零值: false

允许读取和选择内容,但禁止编辑。

Placeholderstring

Go 零值: ""

没有输入或选择时的占位文字。

ColorColor

Go 零值: ColorDefault

语义颜色;默认值继承主题或组件配色。

VariantVariant

Go 零值: VariantDefault

组件外观样式,支持范围取决于组件。

SizeSize

Go 零值: SizeDefault

组件尺寸;默认值继承主题或组件尺寸。

Separator[]int

Go 零值: nil

在指定的 1 基位置后插入分隔符。

SeparatorEveryint

Go 零值: 0

每隔指定格数插入分隔符。

OnChangefunc(string)

Go 零值: nil

值发生变化时通知应用的回调。

OnCompletefunc(string)

Go 零值: nil

输入完整值时通知应用的回调。

UIStyles

Go 零值: zero value

以部件名称为键覆盖外观和间距。

Stylefunc(Slot, ui.Element)

Go 零值: nil

同步配置当前构建的部件;不要保留 Element。