主题设置

选择强调色与基础色,保存后全站生效。

强调色
基础色
点击切换锁定状态
显示侧边栏
隐藏侧边栏

OTP 输入

使用一组独立的输入框来采集一次性密码。

<flux:otp wire:model="code" length="6" />

示例用法

显示一个用于验证一次性密码的表单。

验证你的账号

请输入来自认证器应用的一次性密码。

OTP 验证码
<flux:card>    <form wire:submit="verify" class="space-y-8">        <div class="max-w-64 mx-auto space-y-2">            <flux:heading size="lg" class="text-center">Verify your account</flux:heading>            <flux:text class="text-center">Please enter a one-time password from the authenticator app.</flux:text>        </div>        <flux:otp wire:model="code" length="6" label="OTP Code" label:sr-only :error:icon="false" error:class="text-center" class="mx-auto" />        <div class="space-y-4">            <flux:button variant="primary" type="submit" class="w-full">Verify</flux:button>            <flux:button wire:click="resend" class="w-full">Resend code</flux:button>        </div>    </form></flux:card>

自动提交

使用 submit="auto" 属性,在所有输入框填满后自动提交表单。

验证你的账号

请输入来自认证器应用的一次性密码。

<form wire:submit="verify" class="space-y-8">    <div class="max-w-64 mx-auto space-y-2">        <flux:heading size="lg" class="text-center">Verify your account</flux:heading>        <flux:text class="text-center">Please enter a one-time password from the authenticator app.</flux:text>    </div>    <div class="space-y-6">        <flux:otp wire:model="code" length="6" submit="auto" class="mx-auto" />    </div></form>

字母数字模式

通过将 mode 设置为 alphanumericalpha,允许输入非数字字符。

许可证密钥
请输入安装光盘上印刷的许可证密钥
<flux:otp wire:model="licenseKey" length="10" mode="alphanumeric" label="License key" description:trailing="Enter the license key printed on the installation disc" />

隐私模式

若要遮蔽敏感输入值,请使用 private 属性。

PIN 码
<flux:otp wire:model="pin" length="4" private label="PIN Code" />

分隔符

使用默认插槽渲染输入框,并在它们之间插入分隔符。

<flux:otp wire:model="code">    <flux:otp.input />    <flux:otp.input />    <flux:otp.input />    <flux:otp.separator />    <flux:otp.input />    <flux:otp.input />    <flux:otp.input /></flux:otp>

分组

使用 flux:otp.group 组件将所有输入框分组在一起。

<flux:otp wire:model="code">    <flux:otp.group>        <flux:otp.input />        <flux:otp.input />        <flux:otp.input />        <flux:otp.input />        <flux:otp.input />        <flux:otp.input />    </flux:otp.group></flux:otp>

分组分隔符

使用 flux:otp.separator 组件在输入框分组之间添加分隔符。

<flux:otp wire:model="code">    <flux:otp.group>        <flux:otp.input />        <flux:otp.input />        <flux:otp.input />    </flux:otp.group>    <flux:otp.separator />    <flux:otp.group>        <flux:otp.input />        <flux:otp.input />        <flux:otp.input />    </flux:otp.group></flux:otp>

参考

flux:otp

属性
描述
wire:model
将值绑定到 Livewire 属性。更多信息请参阅 wire:model 文档
value
当前值,字符串类型。
length
要显示的输入框数量。
mode
输入模式。可选值为 numeric (默认)、 alphanumeric ,或 alpha
private
将输入框设置为 private 类型,以遮蔽输入值。
submit
控制通过键盘提交表单的行为。 可选值:默认, auto 表示在所有输入框填满时提交。
autocomplete
为第一个输入框设置 autocomplete 属性。 使用 off 可以关闭浏览器自动填充。默认值为 one-time-code .
插槽
描述
default
自定义输入框和分隔符。使用该插槽时, length 属性将被忽略。

flux:otp.input

属性
描述

flux:otp.separator

属性
描述

flux:otp.group

插槽
描述
默认
组内包含的输入框。
© 2025 FluxProMax™. All Rights Reserved.

备案号:皖ICP备13019729号-11

网站导航