Skip to content

Commit bc94685

Browse files
committed
Support bare col and row utilities
1 parent 98359be commit bc94685

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

packages/tailwindcss/src/utilities.test.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,8 @@ test('order', async () => {
11061106
test('col', async () => {
11071107
expect(
11081108
await run([
1109+
'col-11',
1110+
'-col-12',
11091111
'col-auto',
11101112
'col-span-4',
11111113
'col-span-17',
@@ -1114,7 +1116,15 @@ test('col', async () => {
11141116
'col-span-[var(--my-variable)]',
11151117
]),
11161118
).toMatchInlineSnapshot(`
1117-
".col-\\[span_123\\/span_123\\] {
1119+
".-col-12 {
1120+
grid-column: calc(12 * -1);
1121+
}
1122+
1123+
.col-11 {
1124+
grid-column: 11;
1125+
}
1126+
1127+
.col-\\[span_123\\/span_123\\] {
11181128
grid-column: span 123 / span 123;
11191129
}
11201130
@@ -1233,6 +1243,8 @@ test('col-end', async () => {
12331243
test('row', async () => {
12341244
expect(
12351245
await run([
1246+
'row-11',
1247+
'-row-12',
12361248
'row-auto',
12371249
'row-span-4',
12381250
'row-span-17',
@@ -1241,7 +1253,15 @@ test('row', async () => {
12411253
'row-span-[var(--my-variable)]',
12421254
]),
12431255
).toMatchInlineSnapshot(`
1244-
".row-\\[span_123\\/span_123\\] {
1256+
".-row-12 {
1257+
grid-row: calc(12 * -1);
1258+
}
1259+
1260+
.row-11 {
1261+
grid-row: 11;
1262+
}
1263+
1264+
.row-\\[span_123\\/span_123\\] {
12451265
grid-row: span 123 / span 123;
12461266
}
12471267

packages/tailwindcss/src/utilities.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,11 @@ export function createUtilities(theme: Theme) {
585585
*/
586586
staticUtility('col-auto', [['grid-column', 'auto']])
587587
functionalUtility('col', {
588+
supportsNegative: true,
589+
handleBareValue: ({ value }) => {
590+
if (!isPositiveInteger(value)) return null
591+
return value
592+
},
588593
themeKeys: ['--grid-column'],
589594
handle: (value) => [decl('grid-column', value)],
590595
})
@@ -653,6 +658,11 @@ export function createUtilities(theme: Theme) {
653658
*/
654659
staticUtility('row-auto', [['grid-row', 'auto']])
655660
functionalUtility('row', {
661+
supportsNegative: true,
662+
handleBareValue: ({ value }) => {
663+
if (!isPositiveInteger(value)) return null
664+
return value
665+
},
656666
themeKeys: ['--grid-row'],
657667
handle: (value) => [decl('grid-row', value)],
658668
})

0 commit comments

Comments
 (0)