Skip to content

Commit 7ea8cbe

Browse files
authored
Document tab-* utilities (#2485)
Direct link: https://tailwindcss-com-git-feat-document-tab-utilities-tailwindlabs.vercel.app/docs/tab-size This PR documents the `tab-*` utilities introduced by: tailwindlabs/tailwindcss#20022 The syntax highlighting is done by the MDX pipeline we have (shiki) but because if that the MDX looks a bit... insane. It did allow us to go from MDX to JSX to MDX and back. <img width="1694" height="1856" alt="image" src="https://github.com/user-attachments/assets/fa13ffef-ec86-4e66-8dd2-fd8cc5901b14" />
1 parent 05e875d commit 7ea8cbe

3 files changed

Lines changed: 76 additions & 0 deletions

File tree

src/app/(docs)/docs/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export default {
108108
["text-overflow", "/docs/text-overflow"],
109109
["text-wrap", "/docs/text-wrap"],
110110
["text-indent", "/docs/text-indent"],
111+
["tab-size", "/docs/tab-size"],
111112
["vertical-align", "/docs/vertical-align"],
112113
["white-space", "/docs/white-space"],
113114
["word-break", "/docs/word-break"],

src/docs/tab-size.mdx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { ApiTable } from "@/components/api-table.tsx";
2+
import { ResponsiveDesign, UsingACustomValue } from "@/components/content.tsx";
3+
import { Example } from "@/components/example.tsx";
4+
import { Figure } from "@/components/figure.tsx";
5+
6+
export const title = "tab-size";
7+
export const description = "Utilities for controlling the size of tab characters.";
8+
9+
<ApiTable
10+
rows={[
11+
["tab-<number>", "tab-size: <number>;"],
12+
["tab-(<custom-property>)", "tab-size: var(<custom-property>);"],
13+
["tab-[<value>]", "tab-size: <value>;"],
14+
]}
15+
/>
16+
17+
## Examples
18+
19+
### Basic example
20+
21+
Use `tab-<number>` utilities like `tab-2` and `tab-8` to control the size of tab characters:
22+
23+
<Figure>
24+
25+
<Example>
26+
<div className="grid gap-6 sm:grid-cols-2">
27+
<div className="tab-2">
28+
<span className="mb-3 block font-mono text-xs font-medium text-gray-500 dark:text-gray-400">tab-2</span>
29+
30+
{/* prettier-ignore */}
31+
```jsx
32+
function indent() {
33+
return 'tabbed';
34+
}
35+
```
36+
37+
</div>
38+
<div className="tab-8">
39+
<span className="mb-3 block font-mono text-xs font-medium text-gray-500 dark:text-gray-400">tab-8</span>
40+
41+
{/* prettier-ignore */}
42+
```jsx
43+
function indent() {
44+
return 'tabbed';
45+
}
46+
```
47+
48+
</div>
49+
50+
</div>
51+
</Example>
52+
53+
```html
54+
<!-- [!code classes:tab-2,tab-8] -->
55+
<pre class="tab-2 ...">function indent() {&#10;&#9;return 'tabbed'&#10;}</pre>
56+
<pre class="tab-8 ...">function indent() {&#10;&#9;return 'tabbed'&#10;}</pre>
57+
```
58+
59+
</Figure>
60+
61+
### Using a custom value
62+
63+
<UsingACustomValue element="pre" utility="tab" name="tab size" value="12px" variable="tab-size" />
64+
65+
### Responsive design
66+
67+
<ResponsiveDesign element="pre" property="tab-size" defaultClass="tab-4" featuredClass="tab-8" />

src/docs/theme.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ Defining new theme variables in these namespaces will make new corresponding uti
190190
Line height utilities like <code>leading-tight</code>
191191
</td>
192192
</tr>
193+
<tr>
194+
<td className="whitespace-nowrap">
195+
<code>--tab-size-*</code>
196+
</td>
197+
<td>
198+
Tab size utilities like <code>tab-github</code>
199+
</td>
200+
</tr>
193201
<tr>
194202
<td className="whitespace-nowrap">
195203
<code>--breakpoint-*</code>

0 commit comments

Comments
 (0)