---
title: "वन-टाइम कोड फ़ील्ड"
description: "व्यक्ति को भेजा गया छोटा कोड एक पूरे फ़ील्ड के रूप में माँगता है: लेबल के नीचे सेल, सहायता की एक पंक्ति और ग़लत कोड के लिए शब्द। ये सब सहायक तकनीक के लिए आपस में जुड़े रहते हैं, और फ़ॉर्म में यह एक ही कंट्रोल के रूप में हिस्सा लेता है।"
url: "https://tanrei.chnotchy.com/hi/components/one-time-code-field/"
last_updated: 2026-10-23T21:17:12.000Z
---

# वन-टाइम कोड फ़ील्ड

> व्यक्ति को भेजा गया छोटा कोड एक पूरे फ़ील्ड के रूप में माँगता है: लेबल के नीचे सेल, सहायता की एक पंक्ति और ग़लत कोड के लिए शब्द। ये सब सहायक तकनीक के लिए आपस में जुड़े रहते हैं, और फ़ॉर्म में यह एक ही कंट्रोल के रूप में हिस्सा लेता है।

## अवलोकन

वन-टाइम कोड फ़ील्ड वहाँ इस्तेमाल करें जहाँ प्रॉडक्ट अपना भेजा हुआ छोटा कोड वापस माँगता है: साइन इन करने के लिए, किसी पते या फ़ोन नंबर की पुष्टि के लिए, किसी भुगतान को मंज़ूरी देने के लिए। यह आम स्थिति के लिए है, और इस्तेमाल के लिए तैयार है: एक लेबल, सेल, एक पंक्ति जो बताती है कि कोड कहाँ भेजा गया, और ग़लत कोड के लिए शब्द।

**किनसे बना है:** एक [फ़ील्ड](https://tanrei.chnotchy.com/hi/components/field/) और एक [वन-टाइम कोड इनपुट](https://tanrei.chnotchy.com/hi/components/one-time-code-input/) से। फ़ील्ड फ़्रेम है: लेबल, ज़रूरी या वैकल्पिक का निशान, सहायता और त्रुटि। वन-टाइम कोड इनपुट कंट्रोल है: सेल, और वह सब जो व्यक्ति उनमें करता है। वन-टाइम कोड फ़ील्ड अपना कुछ नहीं बनाता और उसका कोई टोकन नहीं है: उसकी हर प्रॉपर्टी इन दोनों में से किसी एक की प्रॉपर्टी है, जो उसी को बिना बदले दे दी जाती है।

यह उतना ही चौड़ा होता है जितनी वह जगह जिसमें इसे रखा गया है, और सेल इसके शुरुआती किनारे से शुरू होते हैं।

वेब पर यह `<tanrei-one-time-code-field>` है। बाक़ी प्लैटफ़ॉर्म ने इसे अभी इम्प्लीमेंट नहीं किया है।

### इस्तेमाल

`value` अब तक दर्ज किया गया कोड है, जिसमें कोई सेपरेटर नहीं होता, ग्रुप चाहे जैसे दिखाए गए हों। चारों इवेंट वन-टाइम कोड इनपुट के अपने हैं, और जब इनमें से कोई भी सुना जाता है, तब फ़ील्ड के `value` में नया मान आ चुका होता है।

**Web**

```html
<form>
  <tanrei-one-time-code-field name="code" label="पुष्टि कोड"
    supporting-text="आपके फ़ोन पर भेजा गया 6 अंकों का कोड दर्ज करें।"
    error-text="यह कोड सही नहीं है। संदेश देखकर फिर कोशिश करें।"
    required required-text="ज़रूरी"
    group-size="3"></tanrei-one-time-code-field>
</form>

<script type="module">
  import '@tanrei/web/components/one-time-code-field';

  const code = document.querySelector('tanrei-one-time-code-field');
  // व्यक्ति ने मान बदला। value में नया मान आ चुका है।
  code.addEventListener('input', () => (code.error = false));
  // आख़िरी सेल भरा गया, या पूरा कोड पेस्ट या ऑटोफ़िल हुआ। इसके अलावा अपने आप कुछ नहीं होता।
  code.addEventListener('complete', async (e) => {
    code.readOnly = true;
    const right = await verify(e.detail.value);
    code.readOnly = false;
    code.error = !right;
  });
</script>
```

**React**

```tsx
import { OneTimeCodeField } from '@tanrei/react';

<OneTimeCodeField name="code" label="पुष्टि कोड" error={wrong}
  supportingText="आपके फ़ोन पर भेजा गया 6 अंकों का कोड दर्ज करें।"
  errorText="यह कोड सही नहीं है। संदेश देखकर फिर कोशिश करें।"
  groupSize={3} value={code}
  onInput={(event) => setCode(event.currentTarget.value)}
  onComplete={(event) => verify(event.detail.value)} />
```

### एक स्तर नीचे

वही फ़ील्ड, उसके दोनों सदस्यों से हाथ से लिखा जाए, तो वैसा ही दिखता है और सहायक तकनीक के लिए वही टेक्स्ट बॉक्स होता है:

```html
<tanrei-field label="पुष्टि कोड"
  supporting-text="आपके फ़ोन पर भेजा गया 6 अंकों का कोड दर्ज करें।"
  error-text="यह कोड सही नहीं है। संदेश देखकर फिर कोशिश करें।">
  <tanrei-one-time-code-input name="code" group-size="3"></tanrei-one-time-code-input>
</tanrei-field>
```

एक स्तर नीचे तब जाएँ जब आपको ऐसी व्यवस्था चाहिए जो वन-टाइम कोड फ़ील्ड नहीं देता:

| आपको चाहिए | इस्तेमाल करें |
| --- | --- |
| लेबल, सेल, सहायता और त्रुटि | वन-टाइम कोड फ़ील्ड |
| फ़्रेम के भीतर, सेल के बग़ल में अपनी कोई चीज़, जैसे कोड दोबारा भेजने का कंट्रोल या काउंटडाउन | एक [फ़ील्ड](https://tanrei.chnotchy.com/hi/components/field/), जिसके भीतर एक [वन-टाइम कोड इनपुट](https://tanrei.chnotchy.com/hi/components/one-time-code-input/) और आपका अपना एलिमेंट है |
| सिर्फ़ सेल, ऐसे लेबल के नीचे जो कहीं और दिखाया गया है, जैसे डायलॉग का शीर्षक या किसी चरण का शीर्षक | अकेला [वन-टाइम कोड इनपुट](https://tanrei.chnotchy.com/hi/components/one-time-code-input/), जिसे नाम उसके अपने `label` से मिलता है |
| बिना सेल का एक बॉक्स, ऐसे कोड के लिए जिसकी लंबाई पता नहीं है | `autocomplete="one-time-code"` वाला [टेक्स्ट फ़ील्ड](https://tanrei.chnotchy.com/hi/components/text-field/) |

एक स्तर नीचे जो बदलता है, वह यह है कि कौन-सी बात कहाँ कही जाती है। `name` और `value` वन-टाइम कोड इनपुट पर होते हैं, जो तब वह कंट्रोल है जो फ़ॉर्म को मिलता है, और उसके इवेंट उसी पर सुने जाते हैं। `label`, `error` और `disabled` फ़ील्ड पर ही रहते हैं, जो उन्हें कंट्रोल तक पहुँचाता है: इनपुट के अपने `label`, `error` और `disabled` सेट न करें।

## स्पेक

### हर सदस्य क्या देता है

| पहलू | फ़ील्ड से | वन-टाइम कोड इनपुट से |
| --- | --- | --- |
| प्रॉपर्टी | `label`, `labelHidden`, `supportingText`, `errorText`, `error`, `disabled`, `required`, `optional`, `requiredMark`, `requiredText`, `optionalText` | `value`, `length`, `type`, `groupSize`, `mask`, `readOnly` |
| इवेंट | — | `input`, `change`, `complete`, `action` |
| स्लॉट | `label-icon` | — |
| टोकन | `comp.field.*` | `comp.one-time-code-input.*` |

वन-टाइम कोड इनपुट के अपने `label`, `error` और `disabled` होते हैं। वे वन-टाइम कोड फ़ील्ड की प्रॉपर्टी नहीं हैं: फ़ील्ड का `label` कंट्रोल को नाम देता है, उसका `error` सेल को त्रुटि की अवस्था में लाता है और उसका `disabled` उन्हें अक्षम करता है। इसलिए आप इनमें से हर एक को एक ही बार सेट करते हैं, वन-टाइम कोड फ़ील्ड पर, और उसका लेबल कंट्रोल के साथ बदलता है।

सेल क्या करते हैं, यानी टाइप करना, पेस्ट करना, ऐरो कुंजियाँ, ग्रुप, यह [वन-टाइम कोड इनपुट के पेज](https://tanrei.chnotchy.com/hi/components/one-time-code-input/) पर है। फ़्रेम क्या करता है, यानी ज़रूरी का निशान, सहायता, त्रुटि और वह कैसे पढ़कर सुनाई जाती है, यह [फ़ील्ड के पेज](https://tanrei.chnotchy.com/hi/components/field/) पर है।

### किसी एक फ़ील्ड को अलग करना

वन-टाइम कोड फ़ील्ड का अपना कोई टोकन नहीं है। उसका फ़्रेम फ़ील्ड के टोकन पढ़ता है और उसके सेल वन-टाइम कोड इनपुट के, वे जहाँ भी सेट हों। किसी एक इंस्टेंस को बदलने के लिए, उस पर सदस्य का टोकन सेट करें:

```html
<tanrei-one-time-code-field label="पुष्टि कोड"
  style="--tanrei-comp-field-label-gap: 12px"></tanrei-one-time-code-field>
```

- Category: Text inputs
- Level: composed
- Listing: default
- Built from: Field, One-time-code input
- Page: https://tanrei.chnotchy.com/components/one-time-code-field/
- Spec: https://github.com/chnotchy/tanrei/blob/main/specs/one-time-code-field.spec.json

### Availability

| Design system | Has it | Notes |
| --- | --- | --- |
| Tanrei (`tanrei`) | Yes | — |
| Cupertino (Apple HIG-inspired) (`cupertino`) | Yes | — |
| M3 Expressive-like (Material 3 Expressive-inspired) (`m3-expressive-like`) | Yes | — |
| M3-like (Material 3-inspired) (`m3-like`) | Yes | — |

### Platforms

- Web: the element `<tanrei-one-time-code-field>`, registered by importing `@tanrei/web` (or only its own module, `@tanrei/web/components/one-time-code-field`).
- React: `OneTimeCodeField` from `@tanrei/react`.

| Platform | Name | Status |
| --- | --- | --- |
| Web | `tanrei-one-time-code-field` | lagging |
| SwiftUI | `TanreiOneTimeCodeField` | planned |
| Jetpack Compose | `TanreiOneTimeCodeField` | planned |
| Flutter | `TanreiOneTimeCodeField` | planned |
| React Native | `OneTimeCodeField` | planned |

Names a platform gives in its own idiom:

| Spec | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
| --- | --- | --- | --- | --- | --- |
| `label` (prop) | `label` | `label` | `label` | `labelText` | `label` |
| `labelHidden` (prop) | `labelHidden` | `labelsHidden` | `labelHidden` | `labelHidden` | `labelHidden` |
| `supportingText` (prop) | `supportingText` | `supportingText` | `supportingText` | `helperText` | `supportingText` |
| `error` (prop) | `error` | `error` | `isError` | `isError` | `error` |
| `disabled` (prop) | `disabled` | `disabled` | `enabled` | `enabled` | `disabled` |
| `required` (prop) | `required` | `isRequired` | `required` | `required` | `required` |
| `optional` (prop) | `optional` | `isOptional` | `optional` | `optional` | `optional` |
| `value` (prop) | `value` | `code` | `value` | `controller` | `value` |
| `mask` (prop) | `mask` | `isMasked` | `masked` | `obscureText` | `secureTextEntry` |
| `input` (event) | `input` | `code` | `onValueChange` | `onChanged` | `onChangeText` |
| `change` (event) | `change` | `onCommit` | `onCommit` | `onCommit` | `onEndEditing` |
| `complete` (event) | `complete` | `onComplete` | `onComplete` | `onCompleted` | `onComplete` |
| `action` (event) | `action` | `onSubmit` | `keyboardActions` | `onSubmitted` | `onSubmitEditing` |

Statuses: `planned` — In the inventory. Nothing shippable exists yet. `lagging` — An implementation of an earlier spec exists; it has not caught up with the current one. `alpha` — Implemented with tests. The API may still change. `beta` — Feature complete and at parity. Only fixes are expected. `stable` — Covered by semantic versioning. `deprecated` — Still shipped; scheduled for removal.

### Anatomy

- `field`: The frame: a Field, whole — its label row with the label glyph and the requirement mark, and its supporting row, where the error text stands in the help's place or below it (FLD-7). Drawn by the Field from the Field's tokens (FLD-1 to FLD-9).
- `one-time-code-input`: The frame's one control: a One-time-code input, whole — its cells, its characters, its caret and its group marks. Drawn by the One-time-code input from its own tokens (OTC-1 to OTC-3, OTC-15).

### Props

| Prop | Type | Default | Web attribute | Description |
| --- | --- | --- | --- | --- |
| `label` | `string` | `""` | `label` | Names the control, visibly and to assistive technology. Required, unless the control names itself (a checkbox or a switch with its own label): then leave it empty and the field adds only help and an error. (From Field: Always given: the control of a one-time-code field never names itself, so the case of an empty label does not arise.) |
| `labelHidden` | `boolean` | `false` | `label-hidden` | Does not draw the label, which stays the accessible name. For a control whose visible label is elsewhere (a table column, a toolbar). (From Field.) |
| `supportingText` | `string` | `""` | `supporting-text` | Help shown below the control and given to assistive technology as the control's description. While the field is in error it gives way to errorText, unless the design system keeps both (comp.field.error-text.placement append). (From Field.) |
| `errorText` | `string` | `""` | `error-text` | Shown while error is true, in supportingText's place — or below it, which then stays, where the design system's comp.field.error-text.placement is append: what is wrong and how to put it right, in words. (From Field.) |
| `error` | `boolean` | `false` | `error` | Puts the field in the error condition: the error text is drawn, the control is exposed as invalid and, where it has an error condition of its own, drawn in it. What a value means is the product's to validate; the field never sets this itself. (From Field: The one error of the one-time-code field: the Field passes it to the control (FLD-8, OTC-17), whose own error is not a prop here.) |
| `disabled` | `boolean` | `false` | `disabled` | Disables the control and draws the frame as disabled. Disable a framed control here, not on the control, so that its label follows. (From Field: The one disabled of the one-time-code field: the Field passes it to the control (FLD-14, OTC-20), whose own disabled is not a prop here.) |
| `required` | `boolean` | `false` | `required` | What the form asks of the control: true exposes it as required and draws the required mark beside the label. It never validates: a missing answer is the product's to report with error. (From Field.) |
| `optional` | `boolean` | `false` | `optional` | Draws the optional tag after the label and adds optionalText to the control's description, because assistive technology has no state for it. Ignored while required is true: a control is never both. (From Field.) |
| `requiredMark` | `enum`: `auto`, `tag`, `asterisk`, `none` | `"auto"` | `required-mark` | How this control shows that it is required: tag is a small filled Tag with requiredText, asterisk is "*" after the label, none draws nothing and keeps the semantics. Auto takes comp.field.requirement.mark, which follows sys.behavior.requirement-mark, the system's one answer. Ignored unless required is true. (From Field.) |
| `requiredText` | `string` | `""` | `required-text` | The text of the required tag, in the product's language ("Required", "必須"). The product's: Tanrei has no word for it. Empty reads the product's words; with neither, FLD-24 says what is drawn. (From Field.) |
| `optionalText` | `string` | `""` | `optional-text` | The text of the optional tag, in the product's language ("Optional", "任意"); also read to assistive technology as part of the description. The product's: Tanrei has no word for it. Empty reads the product's words. (From Field.) |
| `value` | `string` | `""` | `value` | The code entered so far: at most length characters, digits or, for alphanumeric, digits and upper-case letters, with no separator. One string, whatever the cells and groups drawn. (From One-time-code input.) |
| `length` | `number` | `6` | `length` | How many characters the code has, and so how many cells are drawn. A whole number of 1 or more. (From One-time-code input.) |
| `type` | `enum`: `numeric`, `alphanumeric` | `"numeric"` | `type` | What a cell takes: numeric is the digits 0 to 9, with a numeric keypad; alphanumeric is digits and the letters A to Z, held in upper case, with a general keyboard. (From One-time-code input.) |
| `groupSize` | `number` | `0` | `group-size` | Draws the cells in groups of this many, counted from the first, with a mark between two groups (3 for a six-character code written "123 456"). 0 draws one group. It changes the drawing only: the value has no separator. (From One-time-code input.) |
| `mask` | `boolean` | `false` | `mask` | Draws the platform's obscuring mark in each filled cell in place of its character, and exposes the field as protected. For a screen other people can see; a code that is used once and expires rarely needs it. (From One-time-code input.) |
| `readOnly` | `boolean` | `false` | `readonly` | Keeps the field focusable and its value readable, and lets nothing change it: for the moment a complete code is being checked, when taking focus away would lose the place of a person who must then correct it. (From One-time-code input.) |

### Events

| Event | Description |
| --- | --- |
| `input` | The person changed the value; carries the new value. Emitted for every change, not when the product sets value. (From One-time-code input.) |
| `change` | The person committed a changed value (focus left the field, or the action key was pressed); carries the value. (From One-time-code input.) |
| `complete` | A change by the person left the value length characters long; carries the value. Emitted after input, once for that change. The field does nothing else: checking the code is the product's. (From One-time-code input.) |
| `action` | The person pressed the keyboard's action key (Enter, Return, Done). (From One-time-code input.) |

### Slots

| Slot | Description |
| --- | --- |
| `label-icon` | A glyph before the label. (From Field.) |

### States

`enabled`, `disabled`, `hovered`, `focused`, `error`

### Accessibility

- Role: `textbox`
- Labeling: One text box, the One-time-code input's (OTC-2); the frame has no role. Its accessible name is label, drawn or not (labelHidden), and its description is the supporting text with, in error, the error text after it, with optionalText while optional is true (FLD-10, FLD-11, OTC-22). It is exposed as invalid while error is true, required while required is true, disabled while disabled is true, read-only while readOnly is true, and as a protected text entry while mask is true. The label's drawn text, the requirement mark, the cells, the caret and the group marks are not exposed a second time (FLD-11, OTC-2).
- Minimum target size: yes

| Keys | Action |
| --- | --- |
| Tab / Shift+Tab | Moves focus to the control and on from it: the one-time-code field is one stop, its control's, and adds none (OTF-5). |
| Every other key | The One-time-code input's own, as its spec's keyboard table says (OTC-6, OTC-8 to OTC-11, OTC-13). The one-time-code field handles no key. |

- What the one-time-code field adds to its members is their being one thing: one tag or one call, one set of props, one value and one entry in a form (OTF-2 to OTF-4). The tie between the two — the name, the description, required, invalid, disabled — is not the one-time-code field's: it is what a Field gives any control it frames, and it runs here exactly as it runs in a product's own Field.
- One level down: a Field with a One-time-code input in it, written by the product, is the same picture and the same text box, and the Field's fixtures code-supporting, code-error, code-disabled and code-required-rtl are this component's twins. A product drops to it for an arrangement the one-time-code field does not offer: something of its own inside the frame beside the cells (a resend control, a countdown), or the One-time-code input alone under a dialog's headline, named by its own label.
- The members' notes hold as written and are not repeated: errors are words (the Field's); nothing happens by itself when the code is complete, and paste and the platform's autofill are never blocked (the One-time-code input's).
- The hit area is the control's (OTC-25); the label widens where a press can land without widening what a press does (FLD-12).
- Not pressable: a press focuses the control and is not an action (OTC-25), so BTN-8, BTN-9 and BTN-10 are not copied.
- How a state looks is a value decision of the active design system; components read the state's tokens and never compute the effect themselves.

### Behaviour

Requirements in EARS form, each with its stable id.

- **OTF-1** THE one-time-code field SHALL be a Field whose one control is a One-time-code input, and SHALL draw nothing of its own: every row, text, mark, cell and line it shows is drawn by one of the two, from that component's own tokens, as FLD-1 to FLD-8 and OTC-1 to OTC-3, OTC-7 and OTC-15 to OTC-17 say. THE one-time-code field SHALL have no token, no size and no gap of its own: the Field places the control and gives it its width (FLD-1), and the One-time-code input lays its row out in that width (OTC-1, OTC-23). What it shows SHALL be the picture a product gets by placing that One-time-code input in that Field by hand with the same values, and what assistive technology is told SHALL be the same name, description and states (FLD-10, FLD-11, OTC-22).
- **OTF-2** THE one-time-code field SHALL give each of its props, unchanged, to the member it is from and SHALL hold no state between the two: label, labelHidden, supportingText, errorText, error, disabled, required, optional, requiredMark, requiredText and optionalText are the Field's; value, length, type, groupSize, mask and readOnly are the One-time-code input's. A value a member does not know SHALL be passed on as given and answered by that member (FLD-22, OTC-19). THE one-time-code field SHALL never set the One-time-code input's own label, error or disabled: the Field's label names the control (FLD-10, OTC-22), the Field's error puts it in its error condition (FLD-8, OTC-17) and the Field's disabled disables it (FLD-14, OTC-20), so that each is said once, in the place where the label follows.
- **OTF-3** THE one-time-code field SHALL hold one value, the One-time-code input's. WHEN the person changes it THE one-time-code field's value SHALL be the new one before any event is reported, and THE one-time-code field SHALL report input, change, complete and action as the One-time-code input emits them — the same events, carrying the same value, in the same order and as often (OTC-13, OTC-14) — as its own, adding none and holding none back. WHEN the product sets value THE one-time-code field SHALL show it as OTC-18 says and SHALL report no event.
- **OTF-4** WHERE the platform has forms (the web) THE one-time-code field SHALL be the one control the form meets, and what OTC-29 says of a One-time-code input SHALL hold of the one-time-code field as a whole: it takes name; it submits the code alone, an empty string WHILE it holds none, and nothing WHILE disabled (OTC-20); it is restored on navigation and resets to the value it was first given; and it reports a missing value WHILE required is true and the value is empty, and nothing for a code shorter than length. Its members SHALL add no entry of their own to the form, and the action key SHALL submit the form the one-time-code field belongs to as OTC-13 says, unless action was cancelled.
- **OTF-5** THE one-time-code field SHALL be one stop in the focus order, its control's (FLD-12, OTC-2). WHEN the product moves focus to the one-time-code field THE one-time-code field SHALL pass it to the control, whose active cell is then the one OTC-5 names. A press on the label row SHALL move focus to the control and a press on the supporting row SHALL do nothing (FLD-12); THE one-time-code field SHALL take focus for no other press, SHALL add no key, and SHALL draw no focus indicator of its own: the frame's focused tokens and the active cell's focused line are the members' (FLD-13, OTC-7).
- **OTF-6** THE one-time-code field SHALL hold exactly one control and SHALL take no other from the product: it has no place for a child but the Field's label glyph (FLD-3, FLD-20), so that the cases of FLD-15 — no control, several controls — and of FLD-23 — a control replaced by another — never arise in it. IF the one-time-code field is placed in a Field THEN THE one-time-code field SHALL be drawn as it is and reported in debug builds as a field placed in a Field (FLD-15); WHERE it is placed in a field group THE one-time-code field SHALL follow the group's disabled as a Field does (FGR-14) and SHALL take nothing else from the group.
- **OTF-7** THE one-time-code field SHALL have no words of its own: every word it shows or says is a prop of the Field's, read as FLD-24 says — the instance's, else the product's words of the same name — and the One-time-code input has none (OTC-30). THE one-time-code field SHALL read no key of the product's words itself.
- **OTF-8** THE one-time-code field SHALL add nothing to how its members answer the place they are used in: the layout direction (FLD-18 to FLD-21; OTC-27 and OTC-28, by which the cells stay a left-to-right run and stand at the start edge, under the label), enlarged text (FLD-16, OTC-23, OTC-24), a person's own forced colors (FLD-17, OTC-26) and the caret's reduced motion are each member's own answer. THE one-time-code field SHALL have no direction, size, color or motion setting of its own, and SHALL never be wider than its layout gives it.
- **OTF-9** WHERE the platform has ARIA attributes (the web), WHEN the product sets an aria- attribute on the host, by the attribute or by the ARIA property that reflects it, THE one-time-code field SHALL move it to the data-aria- attribute of the same name, so that the host is no second node with its name, description or state, and SHALL expose it on the element that carries its role — an id reference by the elements it names in the host's tree or a tree around it, an error message as part of the description while the one-time-code field is invalid — except those the one-time-code field owns (aria-label, aria-labelledby, aria-disabled), which it SHALL move and not expose: its name is label (OTF-1). WHEN the product removes the aria- attribute or its data-aria- twin, or sets the ARIA property that reflects it (ariaLabel, ariaDescribedByElements…) to null, THE one-time-code field SHALL take it off that element. WHEN the product sets an aria- attribute the one-time-code field owns THE one-time-code field SHALL report it in debug builds.

### Tokens

As written in the token documents (DTCG): an alias in braces names the token it takes its value from, which each design system resolves. On the web each token is a CSS custom property: `--tanrei` and the name after `tanrei`, joined by hyphens (`tanrei.comp.field.…` → `--tanrei-comp-field-…`).

#### `tanrei.comp.field`

| Token | Type | Value |
| --- | --- | --- |
| `comp.field.label.typescale` | `typography` | `{tanrei.sys.typescale.label}` |
| `comp.field.label.gap` | `dimension` | `{tanrei.sys.space.space100}` |
| `comp.field.label-icon.size` | `dimension` | `{tanrei.sys.icon.small}` |
| `comp.field.label-icon.gap` | `dimension` | `{tanrei.sys.space.space100}` |
| `comp.field.requirement.mark` | `number` | `{tanrei.sys.behavior.requirement-mark}` |
| `comp.field.requirement.gap` | `dimension` | `{tanrei.sys.space.space100}` |
| `comp.field.requirement.asterisk-gap` | `dimension` | `{tanrei.sys.space.space25}` |
| `comp.field.supporting-text.typescale` | `typography` | `{tanrei.sys.typescale.label-small}` |
| `comp.field.supporting-text.gap` | `dimension` | `{tanrei.sys.space.space50}` |
| `comp.field.counter.gap` | `dimension` | `{tanrei.sys.space.space200}` |
| `comp.field.motion.state-duration` | `duration` | `{tanrei.sys.motion.role.state.default}` |
| `comp.field.motion.state-easing` | `cubicBezier` | `{tanrei.sys.motion.easing.state}` |
| `comp.field.standard.label.color` | `color` | `{tanrei.sys.color.on-surface}` |
| `comp.field.standard.label-icon.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.supporting-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.counter.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.required-asterisk.color` | `color` | `{tanrei.sys.color.primary}` |
| `comp.field.standard.error.label.color` | `color` | `{tanrei.sys.color.on-surface}` |
| `comp.field.standard.error.label-icon.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error.supporting-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error.counter.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error.required-asterisk.color` | `color` | `{tanrei.sys.color.primary}` |
| `comp.field.standard.error.value-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.value-text.color` | `color` | `{tanrei.sys.color.on-surface-variant}` |
| `comp.field.standard.error-text.color` | `color` | `{tanrei.sys.color.error}` |
| `comp.field.value-text.typescale` | `typography` | `{tanrei.sys.typescale.label}` |
| `comp.field.value-text.gap` | `dimension` | `{tanrei.sys.space.space200}` |
| `comp.field.error-text.gap` | `dimension` | `{tanrei.sys.space.space50}` |
| `comp.field.error-text.placement` | `number` | `0` |

Per-state tokens, valued by the design system's pattern rules (not written by hand):

- `comp.field.<variant>.<state>.<property>` for the variants `standard`, the states `focused`, `disabled` and the properties `label.color`, `label-icon.color`, `supporting-text.color`, `required-asterisk.color`, `error.label.color`, `error.label-icon.color`, `error.supporting-text.color`, `error.required-asterisk.color`, `counter.color`, `error.counter.color`, `value-text.color`, `error.value-text.color`, `error-text.color`.

### वेब क्या अलग ढंग से बनाता है

- एलिमेंट के शैडो रूट में एक `<tanrei-field>` रहता है, जिसके भीतर एक `<tanrei-one-time-code-input>` है, और कुछ नहीं। एलिमेंट को इंपोर्ट करने से दोनों डिफ़ाइन हो जाते हैं।
- यह फ़ॉर्म से जुड़ा एलिमेंट है। वह `name` और `form` लेता है, सिर्फ़ कोड सबमिट करता है (अक्षम रहते कुछ नहीं), रीसेट होने पर `value` ऐट्रिब्यूट पर लौटता है, अक्षम `<fieldset>` के भीतर ख़ुद भी अक्षम हो जाता है, और जब तक `required` सेट है और वह ख़ाली है, वह फ़ॉर्म को बताता है कि मान नहीं है। उसके दोनों सदस्य फ़ॉर्म में कोई एंट्री नहीं जोड़ते। सेल में Enter एलिमेंट के फ़ॉर्म के डिफ़ॉल्ट बटन को दबाती है; इसे रोकने के लिए `action` को रद्द करें।
- `input`, `change`, `complete` और `action` वन-टाइम कोड इनपुट के CustomEvent हैं, जिनके साथ `detail.value` आता है। उनका टार्गेट यही एलिमेंट है, और हर लिसनर में `event.target.value` कोड होता है।
- भाग: `field` और `one-time-code-input` दोनों सदस्य हैं। उनके अपने भागों के नाम यहाँ वही हैं जो एक स्तर नीचे हैं: `label`, `label-icon`, `requirement-label`, `supporting-text`; `input`, `cell`, `character`, `caret`, `separator`।
- एलिमेंट पर ख़ुद फ़ोकस नहीं जा सकता: `focus()` सेल पर जाता है, और पेज का अपना `<label for>` फ़ोकस वहीं ले जाता है। एलिमेंट पर `autofocus` उसके पहली बार दिखने पर सेल को फ़ोकस देता है, बशर्ते फ़ोकस किसी और चीज़ पर न हो।
- एलिमेंट का कोई रोल नहीं है। उसे `label` से नाम दें, और जहाँ लेबल कहीं और दिखाया गया है वहाँ साथ में `label-hidden` दें। उसे `aria-label` से कभी नाम न दें, जो यहाँ किसी चीज़ को नाम नहीं देता।
- ऐट्रिब्यूट सदस्यों के अपने हैं: `label-hidden`, `supporting-text`, `error-text`, `required-mark`, `required-text`, `optional-text`, `group-size`, `readonly`।
- इसमें एक ही स्लॉट है, `label-icon`। इसके भीतर रखा गया दूसरा कंट्रोल नहीं दिखाया जाता।
- एलिमेंट के डिफ़ाइन होने से पहले उसका कोई साइज़ नहीं होता और वह सिर्फ़ `label-icon` वाला चाइल्ड दिखाता है। उसे `tanrei-one-time-code-field:not(:defined) > *` से छिपाएँ और ऊँचाई के लिए जगह रखें। जिस पेज को स्क्रिप्ट के बिना काम करना है, वह सादे `<input autocomplete="one-time-code" inputmode="numeric">` के चारों ओर एक `<label>` इस्तेमाल करता है, और सहायता उसके बग़ल में रखता है।

## दिशानिर्देश

### करें

- `supportingText` में बताएँ कि कितने अक्षर आने हैं और कोड कहाँ भेजा गया।
- ग्रुप वैसे दिखाएँ जैसे संदेश उन्हें लिखता है: “123 456” के रूप में भेजे गए कोड के लिए `groupSize="3"`।
- कोड ग़लत है, यह शब्दों में बताएँ, `error` और `errorText` से। ग़लत कोड मिटाया जाए या नहीं, यह ख़ुद तय करें: अक्सर एक ही अंक ग़लत होता है।
- जब पूरे कोड की जाँच चल रही हो, तब `disabled` नहीं, `readOnly` इस्तेमाल करें। अक्षम फ़ील्ड से फ़ोकस हट जाता है, और जिस व्यक्ति को उसके बाद कोड ठीक करना है, वह अपनी जगह खो देता है।
- नया कोड माँगने का तरीक़ा, और समय की कोई सीमा हो तो वह भी, फ़ील्ड के बग़ल में रखें। जहाँ उनकी जगह फ़्रेम के भीतर है, वहाँ फ़ील्ड को हाथ से लिखें, एक स्तर नीचे।

### न करें

- वन-टाइम कोड फ़ील्ड को किसी फ़ील्ड के भीतर न रखें। वह पहले से एक फ़ील्ड है; डीबग बिल्ड यह बताता है।
- उसे `aria-label` से नाम न दें। जहाँ कोई लेबल नहीं दिखाया जाना चाहिए, वहाँ `label` और `labelHidden` दें।
- पेस्ट को न रोकें, कोड छिपाया गया हो या नहीं, और व्यक्ति को पहले बताए बिना फ़ोकस कहीं और न ले जाएँ और फ़ॉर्म सबमिट न करें।
- `mask` को आदतन इस्तेमाल न करें। जो कोड एक ही बार इस्तेमाल होता है और जिसकी अवधि ख़त्म हो जाती है, उसे छिपाने की ज़रूरत कम ही पड़ती है, और छिपाने से ग़लती पकड़ना मुश्किल हो जाता है।
- सिर्फ़ इस फ़ील्ड के लिए सेल की नक़ल बनाकर उनकी स्टाइल न बदलें। फ़ील्ड पर सदस्य का टोकन सेट करें।

## सुलभता

### कंपोनेंट क्या सँभालता है

- यह एक टेक्स्ट बॉक्स है, वन-टाइम कोड इनपुट वाला। उसका नाम `label` है, वह दिखाया गया हो या नहीं; उसका विवरण दिखाया जा रहा सहायक या त्रुटि टेक्स्ट है, और जब तक फ़ील्ड वैकल्पिक है, उसके साथ वैकल्पिक वाला टेक्स्ट भी।
- `error` के true रहते वह अमान्य के रूप में दिया जाता है, `required` सेट रहते ज़रूरी के रूप में, `disabled` के true रहते अक्षम के रूप में, `readOnly` के true रहते सिर्फ़ पढ़ने वाले के रूप में, और `mask` के true रहते पासवर्ड फ़ील्ड के रूप में।
- नाम, विवरण और स्टेट ठीक वैसे ही जोड़े जाते हैं जैसे फ़ील्ड उन्हें अपने फ़्रेम के किसी भी कंट्रोल से जोड़ता है। एक स्तर नीचे हाथ से लिखा गया फ़ील्ड वही टेक्स्ट बॉक्स है।
- दिखने वाला लेबल, ज़रूरी या वैकल्पिक का निशान, सेल, कैरेट और ग्रुप के निशान सहायक तकनीक को दूसरी बार नहीं दिए जाते।
- यह एक ही Tab स्टॉप है। लेबल को दबाने से फ़ोकस सेल पर जाता है और कुछ ऑपरेट नहीं होता; सहायता को दबाने से कुछ नहीं होता।
- जो त्रुटि फ़ोकस के वन-टाइम कोड फ़ील्ड में रहते हुए आती है, उसे उसका फ़ील्ड सदस्य एक बार, बिना टोके (polite), पढ़कर सुनाता है।
- दिशा, बड़ा किया गया टेक्स्ट और फ़ोर्स्ड कलर्स, इन तीनों को हर सदस्य अपने ढंग से सँभालता है: दाएँ से बाएँ वाले लेआउट में फ़्रेम मिरर होता है और सेल शुरुआती किनारे पर बाएँ से दाएँ ही चलते हैं; 200% टेक्स्ट पर कुछ नहीं कटता और कुछ भी आड़ा स्क्रॉल नहीं होता।
- इसके अपने कोई शब्द नहीं हैं। ख़ाली छोड़े गए `requiredText` और `optionalText` को फ़ील्ड प्रॉडक्ट के शब्दों से पढ़ता है।

वेब पर ज्ञात कमियाँ इसके सदस्यों की हैं: कोड टाइप करते समय स्क्रीन रीडर क्या कहते हैं, यह ब्राउज़र के एक्सेसिबिलिटी ट्री से पढ़ा गया है, स्क्रीन रीडर से सुना नहीं गया, और एलिमेंट के डिफ़ाइन होने से पहले कुछ नहीं दिखता।

### आपको क्या करना है

- `label` हमेशा दें, उन शब्दों में जो व्यक्ति उस कोड के लिए इस्तेमाल करेगा।
- क्या अपेक्षित है, यह शब्दों में बताएँ: कितने अक्षर, और कोड कहाँ भेजा गया। सेल लंबाई सिर्फ़ उन्हें दिखाते हैं जो उन्हें देख सकते हैं।
- कोड ग़लत है, उसकी अवधि ख़त्म हो चुकी है या वह ज़रूरी है, यह `errorText`, `supportingText` और `required` से बताएँ। रंग कभी अकेला संकेत नहीं होता।
- जहाँ कोड दर्ज करने का समय सीमित है, वहाँ यह बताएँ, और व्यक्ति को और समय या नया कोड माँगने दें।
