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

# कलर फ़ील्ड

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

## अवलोकन

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

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

यह एक ब्लॉक है, उतना ही चौड़ा जितनी वह जगह जिसमें इसे रखा गया है, और इसका बॉक्स उसे पूरा भरता है। इसकी अपनी कोई चौड़ाई नहीं है: फ़ील्ड कम चौड़ा चाहिए, तो उसे कम चौड़ी जगह दें। यह पहले से एक फ़ील्ड है, इसलिए कभी [फ़ील्ड](https://tanrei.chnotchy.com/hi/components/field/) के भीतर नहीं रखा जाता।

वह अपना कोई पिकर नहीं बनाता। `picker` के साथ, अंत में एक बटन पिकर माँगता है: ब्राउज़र का, या वह सरफ़ेस जिसे प्रॉडक्ट पेश करता है।

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

### इस्तेमाल

`value` एक `#` चिह्न और छोटे अक्षरों में छह हेक्साडेसिमल अंक है (`#0f766e`), या कोई रंग न होने पर ख़ाली स्ट्रिंग। वह कभी आधा टाइप किया हुआ टेक्स्ट नहीं होता: जब तक इनपुट में ऐसा कुछ है जो रंग नहीं है, `value` ख़ाली रहता है।

**Web**

```html
<form>
  <tanrei-color-field name="brand" label="ब्रैंड का रंग" value="#0f766e"
    required required-text="ज़रूरी"
    supporting-text="छह अंकों का हेक्स कोड, जैसे #0f766e।"
    invalid-text="छह अंकों का हेक्स कोड डालें, जैसे #0f766e।"
    picker picker-label="रंग चुनें"></tanrei-color-field>
</form>

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

  const brand = document.querySelector('tanrei-color-field');
  // मान बदला: कोई रंग, या ख़ाली स्ट्रिंग। value में पहले से नया मान है।
  brand.addEventListener('input', () => preview(brand.value));
  // व्यक्ति ने बदला हुआ मान कमिट किया: फ़ोकस बाहर गया, Enter दबाई गई, या पिकर बंद हुआ।
  brand.addEventListener('change', () => save(brand.value));
  // ऐसा टेक्स्ट कमिट हुआ जो रंग नहीं है। फ़ील्ड उसे रहने देता है और invalidText दिखाता है,
  // और detail.message में भी वही आता है।
  brand.addEventListener('entryerror', (e) => console.log(e.detail.text, e.detail.message));
  // अपना पिकर पेश करने के लिए: अनुरोध रद्द करें, पिकर खोलें, और value को चुने गए रंग पर सेट करें।
  brand.addEventListener('pickerrequest', (e) => {
    e.preventDefault();
    openMyPicker(e.detail.value).then((color) => (brand.value = color));
  });
</script>
```

**React**

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

<ColorField label="ब्रैंड का रंग" value={brand} picker pickerLabel="रंग चुनें"
  invalidText="छह अंकों का हेक्स कोड डालें, जैसे #0f766e।"
  onChange={(event) => setBrand(event.currentTarget.value)} />
```

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

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

```html
<tanrei-field label="ब्रैंड का रंग" required required-text="ज़रूरी"
  supporting-text="छह अंकों का हेक्स कोड, जैसे #0f766e।">
  <tanrei-color-input name="brand" value="#0f766e"
    invalid-text="छह अंकों का हेक्स कोड डालें, जैसे #0f766e।"
    picker picker-label="रंग चुनें"></tanrei-color-input>
</tanrei-field>
```

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

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

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

## स्पेक

### फ़ील्ड

| भाग | यह क्या है |
| --- | --- |
| लेबल | कंटेनर के ऊपर (`stacked`), जहाँ उसे फ़ील्ड बनाता है, या उसके भीतर फ़्लोट होता हुआ (`filled`, `outlined`), जहाँ उसे कलर इनपुट बनाता है। यही एक्सेसिबल नाम है, चाहे वह दिखाया गया हो या `labelHidden` से छिपाया गया हो |
| ज़रूरी या वैकल्पिक का निशान | लेबल के बाद: `required` के लिए ज़रूरी का टैग, तारांकन या कुछ नहीं, और `optional` के लिए वैकल्पिक का टैग |
| स्वॉच | कंटेनर की शुरुआत में मान का नमूना: एक छोटा चौकोर, जो ठीक मान के रंग से भरा है, एक बारीक रेखा के भीतर। ख़ाली होने पर वह अकेली बारीक रेखा है। वह कोई कंट्रोल नहीं है |
| इनपुट | टेक्स्ट के रूप में मान। एक पंक्ति, जो स्क्रॉल होती है |
| पिकर बटन | `picker` के साथ: अंत में सिर्फ़ आइकन वाला एक text बटन, जिसका नाम `pickerLabel` से आता है |
| सहायक टेक्स्ट | सहायता की एक पंक्ति, जो वहीं से शुरू होती है जहाँ से मान का टेक्स्ट, स्वॉच के बाद। फ़ील्ड के त्रुटि में रहते त्रुटि टेक्स्ट उसकी जगह ले लेता है (जहाँ डिज़ाइन सिस्टम दोनों रखता है, वहाँ उसके नीचे): जब तक `error` true है तब तक `errorText`, और जब तक कमिट किया गया टेक्स्ट रंग नहीं है तब तक `invalidText`, या जहाँ `invalidText` ख़ाली है वहाँ `errorText` |

तीनों वेरिएंट और तीनों साइज़, `small` (32), `medium` (40) और `large` (56), टेक्स्ट फ़ील्ड के हैं। डिफ़ॉल्ट सिस्टम के साथ सिर्फ़ `stacked` आता है। स्वॉच वहाँ रहता है जहाँ टेक्स्ट फ़ील्ड का शुरुआती आइकन रहता है, उसी आइकन के साइज़ में, इसलिए शुरुआती आइकन वाले टेक्स्ट फ़ील्ड के नीचे रखे कलर फ़ील्ड के शुरुआती किनारे उससे मिलते हैं।

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

### मान और टेक्स्ट

| कब | क्या होता है |
| --- | --- |
| व्यक्ति टाइप करता है, पेस्ट करता है या बोलकर लिखवाता है | न कुछ ठुकराया जाता है, न दोबारा लिखा जाता है। पूरा टेक्स्ट पढ़ा जाता है: वह रंग है तो `value` वही रंग है, वरना ख़ाली। `value` बदलने पर `input` फ़ायर होता है |
| फ़ोकस बाहर जाता है, या Enter | टेक्स्ट कमिट होता है। रंग को मान के अपने रूप में दोबारा लिखा जाता है। मान पिछली बार कमिट किए गए मान से अलग हो तो `change` फ़ायर होता है |
| कमिट किया गया टेक्स्ट रंग नहीं है | टेक्स्ट बना रहता है। फ़ील्ड त्रुटि में आ जाता है और `invalidText` दिखाता है, और `entryerror` फ़ायर होता है। अगले संपादन पर त्रुटि ख़त्म हो जाती है |
| टेक्स्ट ख़ाली है | `value` ख़ाली है। यह कभी फ़ील्ड की अपनी त्रुटि नहीं है |
| प्रॉडक्ट `value` सेट करता है | वही रंग दिखाया जाता है, चाहे जो भी टाइप किया गया हो। कोई इवेंट फ़ायर नहीं होता |

टेक्स्ट तब रंग के रूप में पढ़ा जाता है जब, आसपास के स्पेस छोड़कर, वह ठीक छह हेक्साडेसिमल अंक हो, बड़े या छोटे अक्षरों में, `#` चिह्न के साथ या उसके बिना: `0F766E`, `#0f766e` और ` #0F766E `, तीनों `#0f766e` हैं।

बाक़ी सब कुछ रंग नहीं है: तीन अंक (`#0f7`), आठ अंक (`#0f766e80`), कोई नाम (`teal`), कोई फ़ंक्शनल नोटेशन (`rgb(15, 118, 110)`)। टाइप करते समय तीन अंक रंग नहीं होते, क्योंकि टेक्स्ट छह तक पहुँचने के रास्ते में उनसे होकर गुज़रता है; टेक्स्ट कमिट होने पर उन्हें CSS की तरह, हर अंक को दोहराकर छह अंकों के रूप में पढ़ा जाता है: `#0f7` बन जाता है `#00ff77`। न अल्फ़ा है, न वाइड-गैमट रंग।

जब तक व्यक्ति टाइप कर रहा है, कुछ रिपोर्ट नहीं किया जाता। एंट्री की त्रुटि तभी उठती है जब वह कमिट करता है।

### पिकर

`picker` के साथ, फ़ील्ड अपने अंत में एक बटन दिखाता है। उसे सक्रिय करने पर `pickerrequest` फ़ायर होता है, जिसके साथ मान आता है।

| प्रॉडक्ट | क्या होता है |
| --- | --- |
| कुछ नहीं करता | फ़ील्ड ब्राउज़र का अपना कलर पिकर पेश करता है। हर चुनाव व्यक्ति का किया हुआ संपादन है: टेक्स्ट, स्वॉच, `input`। पिकर बंद होने पर `change` फ़ायर होता है और फ़ोकस पिकर बटन पर रहता है |
| अनुरोध रद्द करता है | फ़ील्ड कुछ पेश नहीं करता। प्रॉडक्ट अपनी सरफ़ेस खोलता है, फ़ील्ड से ऐंकर की हुई, और `value` को चुने गए रंग पर सेट करता है। बंद होने पर वह सरफ़ेस फ़ोकस को पिकर बटन पर लौटाती है |

पिकर बटन दिखने पर स्वॉच पर दबाने से पिकर खुलता है, जैसे बटन दबाने से खुलता है; फ़ोकस इनपुट पर नहीं जाता, और कीबोर्ड का रास्ता वही बटन रहता है। बटन न हो तो स्वॉच पर दबाने से फ़ोकस इनपुट पर जाता है, जैसे फ़ील्ड पर कहीं और दबाने से।

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

- **फ़ील्ड से**: प्रॉपर्टी `label`, `labelHidden`, `supportingText`, `errorText`, `error`, `disabled`, `required`, `optional`, `requiredMark`, `requiredText` और `optionalText`; स्लॉट `label-icon`; टोकन `comp.field.*`।
- **कलर इनपुट से**: प्रॉपर्टी `variant`, `size`, `value`, `invalidText`, `picker` और `pickerLabel`; इवेंट `input`, `change`, `pickerRequest` और `entryError`; टोकन: बॉक्स के लिए `comp.input-box.*`, जिन्हें हर इनपुट बॉक्स पढ़ता है, और स्वॉच के लिए `comp.color-input.*`।

कलर इनपुट के अपने `label`, `labelHidden`, `error` और `disabled` होते हैं। कलर फ़ील्ड इन्हें सेट नहीं करता: उसका `label` फ़ील्ड का है, जो इनपुट को नाम देता है और filled या outlined फ़ील्ड में वही है जो बॉक्स में फ़्लोट होता है।

### टोकन

कलर फ़ील्ड का अपना कोई टोकन नहीं है। उसका बॉक्स [कलर इनपुट के टोकन](https://tanrei.chnotchy.com/hi/components/color-input/#%E0%A4%B8%E0%A5%8D%E0%A4%AA%E0%A5%87%E0%A4%95) पढ़ता है, और उसकी पंक्तियाँ, यानी लेबल, निशान, सहायता और त्रुटि, [फ़ील्ड के टोकन](https://tanrei.chnotchy.com/hi/components/field/#%E0%A4%B8%E0%A5%8D%E0%A4%AA%E0%A5%87%E0%A4%95) पढ़ती हैं, वे जहाँ भी सेट हों। नीचे की टेबल में फ़ील्ड के टोकन हैं। किसी एक इंस्टेंस को बदलने के लिए, उस पर सदस्य का टोकन सेट करें:

```html
<tanrei-color-field label="ब्रैंड का रंग"
  style="--tanrei-comp-field-label-gap: 12px"></tanrei-color-field>
```

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

### Availability

| Design system | Has it | Notes |
| --- | --- | --- |
| Tanrei (`tanrei`) | Yes | Variants left out: `filled`, `outlined`. |
| 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-color-field>`, registered by importing `@tanrei/web` (or only its own module, `@tanrei/web/components/color-field`).
- React: `ColorField` from `@tanrei/react`.

| Platform | Name | Status |
| --- | --- | --- |
| Web | `tanrei-color-field` | lagging |
| SwiftUI | `TanreiColorField` | planned |
| Jetpack Compose | `TanreiColorField` | planned |
| Flutter | `TanreiColorField` | planned |
| React Native | `ColorField` | planned |

Names a platform gives in its own idiom:

| Spec | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
| --- | --- | --- | --- | --- | --- |
| `value` (prop) | `value` | `hex` | `value` | `controller` | `value` |
| `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` |
| `picker` (prop) | `picker` | `showsPicker` | `onPickerRequest` | `onPickerRequest` | `onPickerRequest` |
| `pickerLabel` (prop) | `pickerLabel` | `pickerLabel` | `pickerContentDescription` | `pickerSemanticLabel` | `pickerAccessibilityLabel` |
| `input` (event) | `input` | `hex` | `onValueChange` | `onChanged` | `onValueChange` |
| `change` (event) | `change` | `onCommit` | `onCommit` | `onCommit` | `onEndEditing` |
| `pickerRequest` (event) | `pickerrequest` | `onPickerRequest` | `onPickerRequest` | `onPickerRequest` | `onPickerRequest` |
| `entryError` (event) | `entryerror` | `onEntryError` | `onEntryError` | `onEntryError` | `onEntryError` |

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 Field: the label row with its glyph and its requirement mark, and the supporting row with the help and the error text. In a look whose input floats the label it draws no label row.
- `color-input`: The color input, as the Field's one control: the box, the swatch, the value as text, the picker button, and the label that floats in the box in the looks that float one.

### Props

| Prop | Type | Default | Web attribute | Description |
| --- | --- | --- | --- | --- |
| `variant` | `enum`: `stacked`, `filled`, `outlined` | `"stacked"` | `variant` | The text input's three looks, so that a color input is drawn as the text inputs beside it. Stacked is a filled box that shows focus and error with a line inside its edge and draws no label: the label of the Field that frames it stands above it. Filled and outlined float the label inside the box. Use one style per form. A design system may leave some out (the Tanrei system ships stacked only) or add values. (From Color input.) |
| `size` | `enum`: `small`, `medium`, `large` | `"medium"` | `size` | Minimum height of the container: stacked 32 / 40 / 56, as tall as a Button of the same size, so that the box and a Button side by side in one row stand as tall as each other; filled and outlined 40 / 48 / 56, which hold the label that floats inside them. These are the text input's three sizes, small for a bar, a toolbar or a dense row of controls. The hit area always meets the minimum target. A design system may add values. (From Color input.) |
| `value` | `string` | `""` | `value` | The color the input holds: a number sign and six hexadecimal digits in lowercase ("#0f766e"), an opaque sRGB color; or empty for no color. It is never a half-typed text: while the input holds something that is not a color, value is empty. (From Color input: What the color field reports as its own is the value its color input holds, in that value's own form (CLF-43, CLI-16, CLI-21).) |
| `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: Names the color input. In a filled or outlined look the input draws it, floating in its box, and the Field draws no label row (FLD-25, CLI-15).) |
| `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: Hides the label wherever it would be drawn: the Field's row, or the input's floating label (FLD-25).) |
| `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 Field puts its color input in the input's own error condition (FLD-8, CLI-9).) |
| `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 Field disables its color input, the picker button with it (FLD-14, CLI-31); the color field is then left out of its form (CLF-44).) |
| `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: The Field exposes its color input as required (FLD-10, CLI-11).) |
| `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.) |
| `invalidText` | `string` | `""` | `invalid-text` | The words for an input committed with a text that is not a color ("Enter six hexadecimal digits, like #0f766e"), in the product's language: given to the Field that frames the input, which shows them as its error text (CLI-20). While it is empty that Field shows its own errorText. (From Color input: Shown by the Field, in its supporting row (FLD-28).) |
| `picker` | `boolean` | `false` | `picker` | Shows the picker button. Activated, it emits pickerRequest, and where the platform has a color picker of its own the input presents that picker unless the product cancelled the request. The input draws no picker surface itself. (From Color input.) |
| `pickerLabel` | `string` | `""` | `picker-label` | The accessible name of the picker button ("Choose color"). Required while picker is shown. (From Color input.) |

### Events

| Event | Description |
| --- | --- |
| `input` | The person changed the value — by an edit of the text that made it a color, another color or no color, or by a pick in the platform's picker; carries the new value. Not emitted when the product sets value, nor for an edit that leaves value as it was. (From Color input.) |
| `change` | The person committed a changed value: focus left the input, the action key was pressed, or the platform's picker closed; carries the value. (From Color input.) |
| `pickerRequest` | The person activated the picker button; carries the value. Cancelling it keeps the input from presenting the platform's picker: the product then presents its own surface and sets value to what was picked. (From Color input.) |
| `entryError` | The person committed a text that is not empty and is not a color; carries the text as typed and invalidText, the words the input has for it (empty where the product gave none: the Field that frames the input then shows its own errorText). (From Color input.) |

### Slots

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

### States

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

### Accessibility

- Role: `textbox`
- Labeling: The color field adds nothing to what its members expose and coordinates nothing: the Field gives the color input its name, its description and its required, invalid and disabled states (FLD-8, FLD-10, FLD-11, FLD-14), and the color input carries them on its own element (CLI-11). Assistive technology meets one text box named by label whose value is the color as text, and, while picker is true, one button named by pickerLabel — exactly as it meets a Field around a color input written by hand.
- Minimum target size: yes

| Keys | Action |
| --- | --- |
| Every key | The color input's (its accessibility block; CLI-13, CLI-19, CLI-28). The color field handles no key and adds no focus stop (CLF-45). |

- One level down is the same thing: a Field with a color input in it. Every fixture has that pair as its twin, and the accessibility tree of the two is the same (CLF-43).
- On the web the two members stand in the color field's own shadow root, so the form meets the color field and not the input (CLF-44); focus passes through to the input (CLF-45).
- The color is never told by the swatch alone (WCAG 1.4.1), an error is always words (WCAG 3.3.1), and the swatch alone keeps its color in forced colors: each is the color input's or the Field's, and is said there (CLI-25, CLI-35, FLD-7, FLD-17).

### Behaviour

Requirements in EARS form, each with its stable id.

- **CLF-43** THE color field SHALL be a Field that frames one color input, and nothing else. It SHALL give label, labelHidden, supportingText, errorText, error, disabled, required, optional, requiredMark, requiredText and optionalText to its Field and variant, size, value, invalidText, picker and pickerLabel to its color input, each unchanged; SHALL hold the label-icon slot for its Field; and SHALL emit its color input's events as its own, each once. THE color field SHALL be as wide as the place it stands in, and its color input SHALL fill it: it is a block with no width of its own, as its Field is (FLD-1), around a control that fills the width it is given (CLI-44). Its value SHALL at every moment be the value its color input holds — a color in the value's own form, or the empty string (CLI-16) — and not the text the product set where the two differ (CLI-21). It SHALL draw no part of its own, hold no state of its own and have no token of its own: what it shows, how it behaves and what it exposes to assistive technology SHALL be exactly what that Field and that color input do when a product places the one in the other (FLD-1 to FLD-28; CLI-1 to CLI-44) — the label row and its requirement mark (FLD-2 to FLD-6), or the label that floats in the box with the Field's row left out (FLD-25, CLI-15, CLI-7); the supporting row, started at the value's text, after the swatch (FLD-7 to FLD-9, FLD-26, CLI-43); the name, the description and the states (FLD-10, FLD-11, FLD-14, CLI-11); and the entry error of a text that is not a color, shown in the Field's row (FLD-28, CLI-20).
- **CLF-44** WHERE the platform has forms (the web) THE color field SHALL be the one control the form sees: it SHALL take name, submit its color input's value, reset to the value it was first given, restore it on navigation, report to the form's constraint validation exactly what its color input would report there (CLI-11, CLI-20), and be left out WHILE disabled is true or a disabled group of the form holds it; its color input and its Field SHALL take no part in the form themselves. WHEN the action key asks for the form's submission (CLI-19) the form asked SHALL be the color field's own.
- **CLF-45** WHEN the color field is given focus — by the product, by a press on any part of it that FLD-12 or CLI-24 gives to the input, or by a form that reports its validity — THE color field SHALL pass the focus to the input of its color input, never to the picker button, and SHALL add no stop to the focus order: the stops inside it are its color input's, in that input's order (the input, then the picker button while it is shown, CLI-13). WHILE focus is anywhere inside it, the picker button included, THE color field SHALL count as focused for its Field, whose rows take their focused colors (FLD-13); the box takes its own only WHILE its input has focus (CLI-22). WHEN a picker the color input presented closes, focus SHALL be on the picker button (CLI-29), inside the color field.
- **CLF-46** IF the color field is placed in a Field THE color field SHALL in debug builds report that it is a field already and that the bare control is the color input, and both SHALL still render (FLD-15). WHILE it stands in a field group THE color field SHALL follow that group's disabled, through its own Field, and take nothing else from the group (FGR-20).
- **CLF-47** THE color field SHALL have no words of its own and SHALL read none: requiredText and optionalText are read by its Field (FLD-24), each from the instance's prop and then from the product's words; invalidText and pickerLabel are the instance's alone and are given to its color input as they are (CLI-42).
- **CLF-48** 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 color 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 color field is invalid — except those the color field owns (aria-label, aria-labelledby, aria-disabled), which it SHALL move and not expose: its name is label (CLF-43). 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 color field SHALL take it off that element. WHEN the product sets an aria- attribute the color field owns THE color 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-color-input>` है, और कुछ नहीं। एलिमेंट को इंपोर्ट करने से दोनों डिफ़ाइन हो जाते हैं।
- कलर फ़ील्ड फ़ॉर्म से जुड़ा एलिमेंट है। वह `name` लेता है और `value` सबमिट करता है: रंग, या ख़ाली स्ट्रिंग। वह `value` ऐट्रिब्यूट पर रीसेट होता है, और जब तक `required` है और `value` ख़ाली है, तब तक मान के न होने की रिपोर्ट करता है, और जब तक एंट्री की त्रुटि बनी है, तब तक ग़लत इनपुट की। उसके दोनों सदस्य फ़ॉर्म में कोई एंट्री नहीं जोड़ते।
- `value` हमेशा कलर इनपुट का होता है: `0F766E` के रूप में सेट किया गया मान `#0f766e` के रूप में वापस पढ़ा जाता है, और जो मान रंग नहीं है, वह ख़ाली स्ट्रिंग के रूप में।
- `input` और `change` सादे इवेंट हैं: `value` एलिमेंट से पढ़ें। `pickerrequest` और `entryerror` CustomEvent हैं, पहला `detail.value` के साथ, दूसरा `detail.text` और `detail.message` के साथ। ये कलर इनपुट के अपने इवेंट हैं, जिनका टार्गेट यही एलिमेंट है। `detail.message` में `invalidText` आता है, और जहाँ आपने उसे नहीं दिया वहाँ वह ख़ाली रहता है, तब भी जब फ़ील्ड उसकी जगह `errorText` दिखा रहा हो।
- भाग: `field` और `color-input` दोनों सदस्य हैं। उनके अपने भागों के नाम यहाँ वही हैं जो एक स्तर नीचे हैं: `label-icon`, `supporting-text`; `container`, `outline`, `active-indicator`, `swatch`, `input`, `picker-button`। `label` और `requirement-label` वे हैं जो दिखाए जाते हैं, उन्हें जो भी सदस्य बनाए; `field-label`, `color-input-label`, `field-requirement-label` और `color-input-requirement-label` किसी एक सदस्य वाले का नाम लेते हैं।
- एलिमेंट पर ख़ुद फ़ोकस नहीं जा सकता और उसका कोई रोल नहीं है: `focus()` इनपुट पर जाता है, पिकर बटन पर कभी नहीं। लेबल की पंक्ति, बॉक्स, स्वॉच (जब पिकर बटन न हो) या फ़्लोट होते लेबल पर दबाने से फ़ोकस इनपुट पर जाता है। सहायता या त्रुटि टेक्स्ट पर दबाने से कुछ नहीं होता।
- जब तक फ़ोकस फ़ील्ड में कहीं भी है, पिकर बटन पर भी, लेबल और सहायता अपने फ़ोकस वाले रंग लेते हैं। बॉक्स अपने फ़ोकस वाले रंग सिर्फ़ तब लेता है जब फ़ोकस उसके इनपुट पर हो।
- उसे `label` से नाम दें, और जहाँ लेबल नहीं दिखाना है वहाँ साथ में `label-hidden` दें। उसे `aria-label` से कभी नाम न दें, जो यहाँ किसी चीज़ को नाम नहीं देता।
- एलिमेंट का अपना कोई शब्द नहीं है। `requiredText` और `optionalText` तब तक ख़ाली हैं जब तक आप उन्हें न दें। `requiredText` के बिना ज़रूरी फ़ील्ड वहाँ तारांकन दिखाता है जहाँ टैग होता।
- ब्राउज़र का पिकर हर ब्राउज़र में अलग है: Chromium में पेज का एक पॉपअप, Firefox और Safari में सिस्टम की कलर विंडो। उसका रूप, उसका स्थान और उसकी कुंजियाँ ब्राउज़र की हैं।
- फ़ुल-विड्थ अक्षरों वाला टेक्स्ट (`＃０ｆ７６６ｅ`) रंग के रूप में नहीं पढ़ा जाता।
- एलिमेंट के डिफ़ाइन होने से पहले उसका कोई साइज़ नहीं होता। ऊँचाई के लिए जगह रखें।

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

### कलर फ़ील्ड या टेक्स्ट फ़ील्ड

| पहलू | कलर फ़ील्ड | टेक्स्ट फ़ील्ड |
| --- | --- | --- |
| क्या रखता है | एक रंग, `#` और छह अंकों के रूप में | कोई भी टेक्स्ट |
| क्या दिखाता है | टेक्स्ट के बग़ल में रंग का नमूना | टेक्स्ट |
| क्या जाँचता है | कि टेक्स्ट एक रंग है | कुछ नहीं |

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

### करें

- ऐसा लेबल लिखें जो बताए कि रंग किसके लिए है, और फ़ॉर्म में उसे दिखता रहने दें।
- मान का रूप `supportingText` में बताएँ। फ़ील्ड के त्रुटि में रहते भी वह टेक्स्ट बना रहता है, इसलिए `invalidText` में उसे दोहराने की ज़रूरत नहीं।
- जहाँ यह मायने रखता है, वहाँ `supportingText` में रंग का नाम शब्दों में दें (“टील”)। हेक्साडेसिमल मान इस बारे में कम ही बताता है कि रंग कैसा दिखता है।
- जब भी `picker` सेट हो, `pickerLabel` दें।
- रंग का मतलब ख़ुद वैलिडेट करें, जैसे किसी बैकग्राउंड के मुक़ाबले उसका कंट्रास्ट या पहले से लिया जा चुका रंग, और उसे `error` और `errorText` से बताएँ।
- जिस पंक्ति में हर रंग का नाम पहले से है, जैसे किसी पैलेट के टोन, वहाँ [कलर इनपुट](https://tanrei.chnotchy.com/hi/components/color-input/) इस्तेमाल करें: वह सिर्फ़ बॉक्स है, जिसे नाम उसके अपने `label` से मिलता है।

### न करें

- रंग को अकेले स्वॉच से न बताएँ। मान टेक्स्ट है; जो व्यक्ति दो नमूनों में फ़र्क़ नहीं कर पाता, वह दो अलग मान पढ़ता है।
- ख़ाली `value` को अपने आप में त्रुटि न मानें। `required` कभी वैलिडेट नहीं करता।
- जब तक व्यक्ति टाइप कर रहा है, `aria-invalid` या `error` सेट न करें। `change` या `entryerror` का इंतज़ार करें।
- कलर फ़ील्ड को फ़ील्ड के भीतर न रखें। वह पहले से एक फ़ील्ड है; फ़ील्ड जिस कंट्रोल को फ़्रेम देता है, वह [कलर इनपुट](https://tanrei.chnotchy.com/hi/components/color-input/) है।

## सुलभता

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

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

वेब पर ज्ञात कमियाँ:

- ब्राउज़र का पिकर Tanrei का नहीं है: उसकी सुलभता ब्राउज़र की अपनी है।
- एलिमेंट के डिफ़ाइन होने से पहले कुछ नहीं दिखता।

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

- हर कलर फ़ील्ड को `label` दें।
- `invalidText` और `pickerLabel` फ़ील्ड पर लिखें, पेज की भाषा में। `requiredText` और `optionalText` फ़ील्ड पर दें, या `setWords({ requiredText, optionalText })` से पूरे प्रॉडक्ट के लिए एक बार। देखें [प्रॉडक्ट के शब्द](https://tanrei.chnotchy.com/hi/foundations/words/)।
- रंग को ख़ुद वैलिडेट करें, `error` सेट करें, और `errorText` ऐसा लिखें कि वह बताए कि रंग कैसे ठीक किया जाए।
- अगर आप अपना पिकर पेश करते हैं, तो उसे पिकर बटन से खोलें, उसे एक नाम दें, और उसके बंद होने पर फ़ोकस को बटन पर लौटाएँ।
