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

# इनलाइन कोड

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

## अवलोकन

इनलाइन कोड वाक्य के भीतर कोड की किसी चीज़ का नाम लेता है: कोई कमांड, प्रॉपर्टी, फ़ाइल या मान। पढ़ने और कॉपी करने के लिए कोड की पंक्तियाँ [कोड ब्लॉक](https://tanrei.chnotchy.com/hi/components/code-block/) हैं। दबाई जाने वाली कुंजियाँ [कीबोर्ड शॉर्टकट](https://tanrei.chnotchy.com/hi/components/keyboard-shortcut/) हैं, जो मॉडिफ़ायर के नाम पढ़कर सुनाता है।

### इस्तेमाल

वेब पर इनलाइन कोड कोई एलिमेंट नहीं, आपके अपने `code` एलिमेंट पर लगी एक क्लास है। टेक्स्ट दस्तावेज़ में ही है, इसलिए खोज, पेज में खोजना और कॉपी किसी स्क्रिप्ट के चलने से पहले ही काम करते हैं। `.tanrei-prose` के भीतर का हर वह `code` जो किसी `pre` में नहीं है, बिना क्लास के उसी तरह बनता है, इसलिए रेंडर किए गए Markdown को कुछ नहीं चाहिए।

SwiftUI, Compose, Flutter और React Native नियोजित हैं: इस पेज के शुरू में हर प्लैटफ़ॉर्म के साथ दिए गए नाम वे हैं जो स्पेक उन्हें देता है, और वहाँ अभी कुछ उपलब्ध नहीं है।

**Web**

```html
<link rel="stylesheet" href="@tanrei/web/tokens.css" />
<link rel="stylesheet" href="@tanrei/web/code.css" />

<!-- Tonal: डिफ़ॉल्ट। -->
<p>पहले <code class="tanrei-code" translate="no" spellcheck="false">npm install</code> चलाएँ।</p>

<!-- Plain: सिर्फ़ टाइपफ़ेस, अपने आसपास के टेक्स्ट के रंग में। -->
<code class="tanrei-code" data-variant="plain">comp.button.container.shape</code>

<!-- पूर्वज एलिमेंट अपने भीतर के हर टुकड़े के लिए चुनता है। -->
<table data-tanrei-code="plain">
  <tr><td><code class="tanrei-code">variant</code></td><td><code class="tanrei-code">filled</code></td></tr>
</table>
```

**React**

```tsx
import '@tanrei/web/code.css';

<p>पहले <code className="tanrei-code" translate="no" spellCheck={false}>npm install</code> चलाएँ।</p>
```

| प्रॉपर्टी | वेब पर |
| --- | --- |
| `text` | एलिमेंट का अपना कॉन्टेंट |
| `variant: tonal` | `data-variant="tonal"` |
| `variant: plain` | `data-variant="plain"` |
| `variant: auto` (डिफ़ॉल्ट) | कोई ऐट्रिब्यूट नहीं। `data-tanrei-code="plain"` या `"tonal"` वाला सबसे नज़दीकी पूर्वज चुनता है, और जहाँ कोई नहीं चुनता वहाँ tonal |

## स्पेक

इनलाइन कोड का अपना कोई साइज़ नहीं है। उसका फ़ॉन्ट साइज़ उस टेक्स्ट का साइज़ है जिसमें वह रखा है, एक अनुपात (`comp.inline-code.label.scale`) से गुणा किया हुआ, जो कोड के टाइपफ़ेस और टेक्स्ट के टाइपफ़ेस को बराबर दिखाता है। बॉडी टेक्स्ट में यह 14 के बग़ल में 13 है। हेडिंग में यह हेडिंग का अपना साइज़ है।

यह अपनी पंक्ति को कभी ऊँचा नहीं करता। फ़िल उतना ही ऊँचा है जितना कोड के टाइपफ़ेस का अपना टेक्स्ट बॉक्स, और उसके ऊपर या नीचे कोई पैडिंग नहीं है।

टुकड़ा अपनी पंक्ति के साथ रैप होता है। वह पहले अपने स्पेस पर टूटता है। बिना स्पेस का जो हिस्सा पंक्ति से लंबा है, वह अक्षरों के बीच टूटता है, और कोई हाइफ़न नहीं जोड़ा जाता, क्योंकि हाइफ़न कोड को बदल देता। वह कभी काटा नहीं जाता और कभी स्क्रॉल नहीं होता।

लिंक के भीतर वह लिंक का रंग लेता है और लिंक की अंडरलाइन उसके नीचे से चलती है। strong टेक्स्ट के भीतर वह वेट के एक स्टेप जितना भारी होता है। वह कभी तिरछा नहीं होता।

वह हमेशा बाएँ से दाएँ रखा जाता है, अपने अलग टुकड़े के रूप में, दाएँ से बाएँ वाले वाक्य में भी।

- Category: Communication
- Level: base
- Listing: default
- Page: https://tanrei.chnotchy.com/components/inline-code/
- Spec: https://github.com/chnotchy/tanrei/blob/main/specs/inline-code.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 class `tanrei-code` on the product's own element, styled by `@tanrei/web/code.css`.

| Platform | Name | Status |
| --- | --- | --- |
| Web | `tanrei-code` | lagging |
| SwiftUI | `TanreiInlineCode` | planned |
| Jetpack Compose | `TanreiInlineCode` | planned |
| Flutter | `TanreiInlineCode` | planned |
| React Native | `InlineCode` | planned |

Names a platform gives in its own idiom:

| Spec | Web | SwiftUI | Jetpack Compose | Flutter | React Native |
| --- | --- | --- | --- | --- | --- |
| `text` (prop) | `textContent` | `text` | `text` | `text` | `children` |
| `variant` (prop) | `data-variant` | `variant` | `variant` | `variant` | `variant` |

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

- `container` (optional): The fill behind the text in the tonal form: as tall as the code face's own text box, with small corners and a little room at each end of every piece of the run. Decorative; the plain form has none.
- `label`: The code: its characters exactly as given, in the code face.
- `outline` (optional): An edge around the fill, where a design system gives it a width. The default system draws none.

### Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `text` | `string` | `""` | The code: the characters exactly as they are to be read and copied ("npm install", "comp.button.container.shape"). Spaces inside it are kept. |
| `variant` | `enum`: `auto`, `tonal`, `plain` | `"auto"` | How the run is set apart. tonal: the code face on a faint fill. plain: the code face alone, in the color of the text around it, for a column or a list whose every entry is code and for text on a colored container. auto, the default, takes what the nearest ancestor chooses for the inline code inside it, and tonal where none does. |

### States

`enabled`

### Accessibility

- Role: `code`
- Labeling: Inline code has no name of its own: it is text, read in its sentence. Its role is code where the platform has one (the web's code element); elsewhere it is plain text. Nothing announces its form.
- Minimum target size: yes

- Not interactive: inline code takes no input and no focus (ICD-11), so there is no target to size; minimumTarget holds trivially. Inside a link it is part of that link's text and target.
- Told from the words around it by its face, not by color (WCAG 1.4.1): the fill is decorative, and the plain form and forced colors (ICD-14) draw none.
- Contrast in the default system: the tonal form's text is on-surface on surface-container-highest, and a link's color on that fill is held at the same ratio — both by the token invariants that hold text roles at 4.5:1 on every surface (7:1 in the high-contrast schemes). The plain form has the contrast of the text it sits in.
- The tonal form's fill is a surface role, so it is correct on a surface. On a colored container (a callout, an inverse tooltip, a filled button) the text color of ICD-3 is not paired with that container's content color: use plain there. A component that hosts text on such a container chooses plain for the inline code inside it (ICD-5).
- Screen readers do not announce the code role by default, so a sentence must make sense when the code is read as words. Symbols are read as the person's settings say; write a name out in the sentence where its spelling matters.
- It reflows (WCAG 1.4.10): a long name breaks rather than scroll the page (ICD-6, ICD-15). No hyphen is added, because a hyphen would change the code.
- Keys to press are a keyboard shortcut, which reads modifier names aloud; inline code would read the characters.

### Behaviour

Requirements in EARS form, each with its stable id.

- **ICD-1** THE inline code SHALL set its text in the family, the weight and the letter spacing of comp.inline-code.label.typescale, at the font size of the text it sits in multiplied by comp.inline-code.label.scale — whatever that text is: a paragraph, a heading of any level, a lead paragraph, a caption, a label, a table cell — and SHALL NOT take the font size or the line height of the code role itself.
- **ICD-2** THE inline code SHALL sit on the baseline of the text it is part of, as a part of that text's line, and SHALL NOT make that line taller or change the distance between lines (PRS-17); its fill, where it has one, SHALL be as tall as the code face's own text box (from its ascent to its descent at the drawn size) and SHALL NOT be padded above or below.
- **ICD-3** WHILE the inline code is drawn tonal (ICD-5) THE inline code SHALL draw behind its text a fill of comp.inline-code.container.color with corners comp.inline-code.container.shape eased by sys.shape.corner-smoothing, extend that fill by comp.inline-code.container.padding-inline before the first and after the last character, draw its text in comp.inline-code.label.color, and, where comp.inline-code.outline.width is above 0, draw an edge of that width in comp.inline-code.outline.color inside the fill; it SHALL draw no elevation.
- **ICD-4** WHILE the inline code is drawn plain (ICD-5) THE inline code SHALL draw no fill, no edge and no padding, and SHALL draw its text in the color of the text it sits in, so that it reads on any container that text reads on.
- **ICD-5** WHILE variant is tonal or plain THE inline code SHALL be drawn in that form; WHILE variant is auto THE inline code SHALL be drawn in the form the nearest ancestor chooses for the inline code inside it (a table whose column is code, a callout, a list of names), and tonal where no ancestor chooses one; WHEN that choice changes while the inline code is shown THE inline code SHALL follow it at once.
- **ICD-6** THE inline code SHALL wrap with the line it sits in: it breaks first at the spaces inside it; a part with no space that is longer than the line SHALL break between any two characters rather than run past the edge of its container; and no hyphen or any other character SHALL be drawn at a break. Each piece of a run that breaks SHALL keep the fill, the corners and both paddings of ICD-3. THE inline code SHALL NOT cut its text and SHALL NOT scroll.
- **ICD-7** THE inline code SHALL draw the characters of text as given: every space is kept, a run of spaces is not collapsed, a line break in text is drawn as one space, and the text is not hyphenated, not capitalised or otherwise transformed, not translated by the platform's translation, not spell-checked and not turned into a link by itself.
- **ICD-8** THE inline code SHALL lay out its text as a left-to-right run of its own, isolated from the text around it, in every layout direction (PRS-26): a path, a call and an operator keep their order inside a right-to-left sentence and reorder nothing beside them; the run takes its place in the sentence by the sentence's own direction.
- **ICD-9** THE inline code SHALL take its layout direction from where it is used — the direction of the nearest ancestor that sets one, and the platform's own where none does — and SHALL have no direction setting of its own; WHEN that direction changes while the inline code is shown THE inline code SHALL draw itself for the new direction at once, without a motion of its own, keeping what it shows.
- **ICD-10** WHERE the inline code sits inside a link THE inline code SHALL draw its text in the link's color in place of comp.inline-code.label.color and the link's underline SHALL run under it; WHERE it sits inside strong text it SHALL gain sys.typescale.emphasis.body of weight over the weight of comp.inline-code.label.typescale, as strong text does (PRS-2); WHERE it sits inside emphasised text it SHALL NOT be slanted.
- **ICD-11** THE inline code SHALL NOT take pointer, touch or keyboard input of its own, SHALL NOT take focus or be a stop in the focus order, and SHALL NOT change anything it draws under a pointer, a press or focus: it has no hovered, focused, pressed, selected or disabled state, draws no state layer and no focus indicator, and emits no event. WHERE it is placed inside an element that takes input (a link, a button, a list item) input over it SHALL reach that element, which draws its own states.
- **ICD-12** THE inline code SHALL expose its text as text, read where it sits in the sentence, with the role of code where the platform has one and no name of its own; it SHALL NOT be announced as anything else and SHALL NOT expose its form. Selecting it SHALL select its characters with the text around it, and copying that selection SHALL yield exactly text: no character stands for the padding of ICD-3.
- **ICD-13** THE inline code SHALL draw all of its text in one color: it takes no syntax roles and SHALL NOT highlight, parse or otherwise interpret what it holds.
- **ICD-14** WHERE the platform draws with a person's own forced colors THE inline code SHALL draw its text in the platform's text color (the link color inside a link) and no fill, and an edge only where comp.inline-code.outline.width is above 0, in that text color: the face tells code from words, so nothing rests on the fill.
- **ICD-15** WHILE the text size is enlarged THE inline code SHALL grow with the text it sits in, keeping the proportion of ICD-1, its padding and its corners; at twice the text size in a container 320 wide it SHALL wrap as ICD-6 says and SHALL NOT cause horizontal scrolling.
- **ICD-16** IF text is empty THE inline code SHALL draw nothing, take no space and expose nothing. WHEN variant names a value this spec does not have THE inline code SHALL be drawn as variant auto, and in debug builds report the unknown value.

### 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.inline-code.…` → `--tanrei-comp-inline-code-…`).

#### `tanrei.comp.inline-code`

| Token | Type | Value |
| --- | --- | --- |
| `comp.inline-code.container.color` | `color` | `{tanrei.sys.color.surface-container-highest}` |
| `comp.inline-code.container.shape` | `dimension` | `{tanrei.sys.shape.corner.extra-small}` |
| `comp.inline-code.container.padding-inline` | `dimension` | `{tanrei.sys.space.space50}` |
| `comp.inline-code.outline.color` | `color` | `{tanrei.sys.color.outline-variant}` |
| `comp.inline-code.outline.width` | `dimension` | `{tanrei.sys.space.space0}` |
| `comp.inline-code.label.color` | `color` | `{tanrei.sys.color.on-surface}` |
| `comp.inline-code.label.typescale` | `typography` | `{tanrei.sys.typescale.code}` |
| `comp.inline-code.label.scale` | `number` | `0.9286` |

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

- `translate="no"` और `spellcheck="false"` आपके ऐट्रिब्यूट हैं, या आपके Markdown रेंडरर के। स्टाइलशीट इन्हें सेट नहीं कर सकती।
- कोड का हाइफ़न वह जगह है जहाँ पंक्ति ख़त्म हो सकती है, इससे पहले कि टुकड़ा अक्षरों के बीच टूटे।
- WebKit रैप होने वाले टुकड़े के हर हिस्से का फ़िल और कोने बनाता है, पर हर सिरे की जगह नहीं: पहले के बाद के हिस्से फ़िल के किनारे से शुरू होते हैं।
- टुकड़े के भीतर का लाइन ब्रेक सिर्फ़ उन ब्राउज़र में एक स्पेस के रूप में बनता है जो `white-space-collapse: preserve-spaces` सपोर्ट करते हैं। टुकड़े को एक ही पंक्ति में लिखें।
- अनजान `data-variant` `auto` के रूप में बनता है, और डीबग बिल्ड में कुछ रिपोर्ट नहीं किया जाता।

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

### Tonal या plain

| वेरिएंट | क्या बनाता है | कब इस्तेमाल करें |
| --- | --- | --- |
| **Tonal** | बहुत हल्के फ़िल पर कोड का टाइपफ़ेस | चलते टेक्स्ट के भीतर कोई नाम |
| **Plain** | सिर्फ़ कोड का टाइपफ़ेस, अपने आसपास के टेक्स्ट के रंग में | वह कॉलम या लिस्ट जिसकी हर एंट्री कोड है, और रंगीन कंटेनर पर का टेक्स्ट |

### करें

- वाक्य ऐसे लिखें कि कोड को शब्दों की तरह बोले जाने पर भी वह पढ़ा जा सके। स्क्रीन रीडर डिफ़ॉल्ट रूप से कोड का रोल पढ़कर नहीं सुनाते।
- रंगीन कंटेनर पर, जैसे स्थिति का कंटेनर या इनवर्स सरफ़ेस, plain इस्तेमाल करें। tonal फ़िल एक सरफ़ेस रोल है और सिर्फ़ सरफ़ेस के साथ जोड़ा जाता है।
- नामों की टेबल या लिस्ट के लिए रूप को एक बार पूर्वज पर सेट करें (`data-tanrei-code="plain"`)।

### न करें

- एम्फ़ेसिस के लिए इनलाइन कोड इस्तेमाल न करें। वह कहता है “यह कोड है”।
- दबाई जाने वाली कुंजियाँ इनलाइन कोड में न रखें। कीबोर्ड शॉर्टकट इस्तेमाल करें।
- इसमें एक पंक्ति से ज़्यादा न रखें। कोड ब्लॉक इस्तेमाल करें।

## सुलभता

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

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

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

- जहाँ नाम की स्पेलिंग मायने रखती है, वहाँ उसे वाक्य में पूरा लिखें, क्योंकि चिह्न वैसे पढ़े जाते हैं जैसा व्यक्ति की सेटिंग कहती हैं।
- टुकड़े पर `translate="no"` लगाएँ, ताकि ब्राउज़र का अनुवाद उसे न छुए।
