Skip to content

Commit 3b559e6

Browse files
committed
add tab-* utilities
1 parent c00da89 commit 3b559e6

4 files changed

Lines changed: 72 additions & 0 deletions

File tree

packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11489,6 +11489,9 @@ exports[`getClassList 1`] = `
1148911489
"stroke-transparent/95",
1149011490
"stroke-transparent/100",
1149111491
"subpixel-antialiased",
11492+
"tab-2",
11493+
"tab-4",
11494+
"tab-8",
1149211495
"table",
1149311496
"table-auto",
1149411497
"table-caption",

packages/tailwindcss/src/property-order.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ export default [
354354
'text-overflow',
355355
'hyphens',
356356
'white-space',
357+
'tab-size',
357358

358359
'color',
359360
'text-transform',

packages/tailwindcss/src/utilities.test.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11807,6 +11807,58 @@ test('whitespace', async () => {
1180711807
).toEqual('')
1180811808
})
1180911809

11810+
test('tab', async () => {
11811+
expect(
11812+
await compileCss(
11813+
css`
11814+
@theme {
11815+
--tab-size-github: 8;
11816+
}
11817+
11818+
@tailwind utilities;
11819+
`,
11820+
['tab-2', 'tab-8', 'tab-[12px]', 'tab-[3]', 'tab-github'],
11821+
),
11822+
).toMatchInlineSnapshot(`
11823+
"
11824+
:root, :host {
11825+
--tab-size-github: 8;
11826+
}
11827+
11828+
.tab-2 {
11829+
tab-size: 2;
11830+
}
11831+
11832+
.tab-8 {
11833+
tab-size: 8;
11834+
}
11835+
11836+
.tab-\\[3\\] {
11837+
tab-size: 3;
11838+
}
11839+
11840+
.tab-\\[12px\\] {
11841+
tab-size: 12px;
11842+
}
11843+
11844+
.tab-github {
11845+
tab-size: var(--tab-size-github);
11846+
}
11847+
"
11848+
`)
11849+
expect(
11850+
await run([
11851+
'tab',
11852+
'-tab-2',
11853+
'tab-2.5',
11854+
'tab-1/2',
11855+
'tab-unknown',
11856+
'tab-2/foo',
11857+
'tab-[12px]/foo',
11858+
]),
11859+
).toEqual('')
11860+
})
11861+
1181011862
test('text-wrap', async () => {
1181111863
expect(await run(['text-wrap', 'text-nowrap', 'text-balance', 'text-pretty']))
1181211864
.toMatchInlineSnapshot(`

packages/tailwindcss/src/utilities.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,22 @@ export function createUtilities(theme: Theme) {
22752275
staticUtility('whitespace-pre-wrap', [['white-space', 'pre-wrap']])
22762276
staticUtility('whitespace-break-spaces', [['white-space', 'break-spaces']])
22772277

2278+
functionalUtility('tab', {
2279+
themeKeys: ['--tab-size'],
2280+
handleBareValue: ({ value }) => {
2281+
if (!isPositiveInteger(value)) return null
2282+
return value
2283+
},
2284+
handle: (value) => [decl('tab-size', value)],
2285+
})
2286+
2287+
suggest('tab', () => [
2288+
{
2289+
values: ['2', '4', '8'],
2290+
valueThemeKeys: ['--tab-size'],
2291+
},
2292+
])
2293+
22782294
staticUtility('text-wrap', [['text-wrap', 'wrap']])
22792295
staticUtility('text-nowrap', [['text-wrap', 'nowrap']])
22802296
staticUtility('text-balance', [['text-wrap', 'balance']])

0 commit comments

Comments
 (0)