kliping.pro
  • Docs
  • Explore
  • Builder
  • Directory
  • Colors
  • Typeset
Saved
Docs
  • Sections13
  • Installation5
  • Dark Mode4
  • Forms3
  • Registry6
  • Utilities2
  • More10
  • Components137
  • Accordion
  • Action Bar
  • AI Chat
  • AI Thread List
  • Alert
  • Alert Dialog
  • Angle Slider
  • Animated Grid Pattern
  • Aspect Ratio
  • Attachment
  • Avatar
  • Avatar Group
  • Badge
  • Badge Overflow
  • Banner
  • Border Beam
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Checkbox Group
  • Chip
  • Circular Progress
  • Client Only
  • Collapsible
  • Color Picker
  • Color Swatch
  • Combobox
  • Combobox Advanced
  • Command
  • Compare Slider
  • Composition
  • Context Menu
  • Cropper
  • Data Grid
  • Data Table
  • Data Table Advanced
  • Date Picker
  • Dialog
  • Direction Provider
  • Dot Pattern
  • Drawer
  • Dropdown Menu
  • Editable
  • Empty
  • Field
  • File Upload
  • Form
  • FPS
  • Gauge
  • Hitbox
  • Hover Card
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kanban
  • Kbd
  • Kbd Advanced
  • Key Value
  • Label
  • List
  • Listbox
  • Logos
  • Map
  • Marker
  • Marquee
  • Mask Input
  • Masonry
  • Media Player
  • Mention
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Number Field
  • Pagination
  • Particles
  • Pending
  • Phone Input
  • Pin Input
  • Popover
  • Portal
  • Presence
  • Progress
  • QR Code
  • Questionnaire
  • Radio Group
  • Range Calendar
  • Rating
  • Relative Time Card
  • Resizable
  • Responsive Dialog
  • Scroll Area
  • Scroll Spy
  • Scroller
  • Segmented Input
  • Select
  • Selection Toolbar
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Software Purchase Card
  • Sonner
  • Sortable
  • Speed Dial
  • Spinner
  • Stack
  • Stat
  • Status
  • Stepper
  • Stepper Advanced
  • Swap
  • Switch
  • Table
  • Tabs
  • Tags Input
  • Tags Input Advanced
  • Textarea
  • Time Picker
  • Timeline
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Tour
  • Typography
  • Visually Hidden
  • Visually Hidden Input
  1. Docs
  2. Components
  3. Input OTP

Input OTP

PreviousNext

Komponen kode sekali pakai yang mudah diakses, lengkap dengan dukungan salin-tempel.

View 7 variants
Docs

Installation ​

pnpm dlx kliping@latest add input-otp

Pasang dependensi berikut:

pnpm add vue-input-otp

Salin dan tempel kode sumber di GitHub ke project Anda.

Sesuaikan path import dengan struktur project Anda.

Usage ​

vue
<script setup lang="ts">
import {
  InputOTP,
  InputOTPGroup,
  InputOTPSeparator,
  InputOTPSlot,
} from '@/components/ui/input-otp'
</script>

<template>
  <InputOTP v-model="value" :maxlength="6">
    <InputOTPGroup>
      <InputOTPSlot :index="0" />
      <InputOTPSlot :index="1" />
      <InputOTPSlot :index="2" />
    </InputOTPGroup>
    <InputOTPSeparator />
    <InputOTPGroup>
      <InputOTPSlot :index="3" />
      <InputOTPSlot :index="4" />
      <InputOTPSlot :index="5" />
    </InputOTPGroup>
  </InputOTP>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

Examples ​

Pola ​

Pakai prop pattern untuk menentukan pola kustom pada input OTP.

vue
<script setup lang="ts">
import { REGEXP_ONLY_DIGITS_AND_CHARS } from 'vue-input-otp'
// ...
</script>

<template>
  <InputOTP
    maxlength="6"
    :pattern="REGEXP_ONLY_DIGITS_AND_CHARS"
  >
    <InputOTPGroup>
      <InputOTPSlot :index="0" />
      <!-- ... -->
    </InputOTPGroup>
  </InputOTP>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Separator ​

Pakai komponen <InputOTPSeparator /> untuk menyisipkan pemisah di antara kelompok input.

vue
<script setup lang="ts">
import {
  InputOTP,
  InputOTPGroup,
  InputOTPSeparator,
  InputOTPSlot,
} from '@/components/ui/input-otp'
// ...
</script>

<template>
  <InputOTP maxlength="4">
    <InputOTPGroup>
      <InputOTPSlot :index="0" />
      <InputOTPSlot :index="1" />
    </InputOTPGroup>
    <InputOTPSeparator />
    <InputOTPGroup>
      <InputOTPSlot :index="2" />
      <InputOTPSlot :index="3" />
    </InputOTPGroup>
  </InputOTP>
</template>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

Dikendalikan dari Luar ​

Pakai direktif v-model untuk mengendalikan nilai input dari luar.

Enter your one-time password.

Form ​

Komponen InputOTP bisa dipakai di dalam form, misalnya bersama VeeValidate.

Please enter the one-time password sent to your phone.

Requirements ​

Semua dipasang otomatis oleh kliping add; tabel ini untuk Anda yang memasang manual atau memeriksa project.

RequirementValue
ProjectVue 3.5+, Tailwind CSS v4, alias @ — disiapkan kliping init
npm packages@lucide/vue@^1.31.0, @vueuse/core@^14.4.0, reka-ui@^2.10.3, vue-input-otp@^0.4.0
Filescomponents/ui/input-otp/input-otp.vue
components/ui/input-otp/input-otp-group.vue
components/ui/input-otp/input-otp-separator.vue
components/ui/input-otp/input-otp-slot.vue
components/ui/input-otp/index.ts

Anatomy ​

Susunan bagiannya seperti dipakai di contoh-contoh di atas. Impor semua bagian dari satu tempat, lalu susun begini:

vue
<InputOTP>
  <InputOTPGroup>
    <InputOTPSlot />
  </InputOTPGroup>
  <InputOTPSeparator />
</InputOTP>

API Reference ​

InputOTP ​

PropTypeDefaultDescription
maxlengthnumber—Number of characters in the code; one slot each.
textAlign?"center" | "right" | "left"—Where the caret sits inside the hidden input; matches the slot that looks active.
inputmode?"numeric" | "text"—Mobile keyboard to show: digits only (numeric) or full (text).
containerClass?string—Classes for the wrapper around the slots; set from class by this component.
pushPasswordManagerStrategy?"increase-width" | "none"—Widen the input so password-manager badges do not cover the last slot.
noScriptCssFallback?string—CSS injected in a <noscript> tag so the input stays usable without JavaScript.
pasteTransformer?((pasted: string) => string)—Cleans pasted text before it is checked against pattern, e.g. strips spaces or dashes.
defaultValue?any—The initial value when uncontrolled.
nonce?string—Applied to the injected <style> tag, for a nonce-based style-src CSP.
disabled?boolean—Prevents the user from interacting with it.
name?string—The name submitted with a form.
readonly?boolean—Shows the value without allowing changes.
required?boolean—Marks it as required when submitted in a form.
size?number—The visual size.

Ditambah atribut <input> bawaan, diteruskan ke elemen input: accept, alt, autocomplete, autofocus, capture, checked, crossorigin, enterKeyHint, form, formaction, formenctype, formmethod, formnovalidate, formtarget, height, indeterminate, list, max, min, minlength, multiple, pattern, placeholder, spellcheck, src, step, type, value, width.

EventPayloadDescription
@input[value: string]Emitted with the current code on every change.
@select[e: Event]Native select event: the text selection inside the input changed.
@complete[value: string]Emitted with the code once every slot is filled.
@change[e: Event]Native change event of the hidden input.
@focus[e: FocusEvent]Emitted when the input gains focus.
@blur[e: FocusEvent]Emitted when the input loses focus.
@mouseover[e: MouseEvent]Emitted when the pointer enters the slots.
@mouseleave[e: MouseEvent]Emitted when the pointer leaves the slots.
@paste[e: ClipboardEvent]Emitted on paste, before pasteTransformer runs.
SlotProps
#default{ slots: SlotProps[]; isFocused: boolean; isHovering: boolean; }
Data attributeValue
[data-slot]"input-otp"

InputOTPGroup ​

SlotProps
#default—
Data attributeValue
[data-slot]"input-otp-group"

InputOTPSeparator ​

SlotProps
#default—
Data attributeValue
[data-slot]"input-otp-separator"

InputOTPSlot ​

PropTypeDefaultDescription
indexnumber—Zero-based position of the OTP character this slot displays.
Data attributeValue
[data-slot]"input-otp-slot"
[data-active]set at runtime

CSS Variables ​

Token tema yang dibaca komponen ini — ubah nilainya di CSS global (:root dan .dark, lihat Theming) untuk mengubah tampilannya tanpa menyentuh komponennya: --border, --destructive, --foreground, --input, --radius, --ring.

Changelog ​

  • 19 Okt 2026 · Fixed — Aksesibilitas: nama aksesibel dan peran ARIA yang sah.

Credits ​

Berasal dari shadcn-vue (MIT, Copyright (c) 2023 unovue). Rantai lengkapnya di Credits.

PreviousInput GroupNext Item

On This Page

InstallationUsageExamplesPolaSeparatorDikendalikan dari LuarFormRequirementsAnatomyAPI ReferenceInputOTPInputOTPGroupInputOTPSeparatorInputOTPSlotCSS VariablesChangelogCredits

© 2026 Kliping. Free components are open source under the MIT License.

LicenseCreditsRoadmap