Skip to content

Commit fe2610e

Browse files
Add field-sizing utilities (#14469)
This PR adds support for the [`field-sizing`](https://developer.mozilla.org/en-US/docs/Web/CSS/field-sizing) property which can be used to fit a text inputs, file inputs, textareas, and selects to the size of the text rather than some implicit default width. --------- Co-authored-by: Adam Wathan <[email protected]>
1 parent 36fb123 commit fe2610e

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Support `screens` in JS config files ([#14415](https://github.com/tailwindlabs/tailwindcss/pull/14415))
1616
- Add `bg-radial-*` and `bg-conic-*` utilities for radial and conic gradients ([#14467](https://github.com/tailwindlabs/tailwindcss/pull/14467))
1717
- Add new `shadow-initial` and `inset-shadow-initial` utilities for resetting shadow colors ([#14468](https://github.com/tailwindlabs/tailwindcss/pull/14468))
18+
- Add `field-sizing-*` utilities ([#14469](https://github.com/tailwindlabs/tailwindcss/pull/14469))
1819

1920
### Fixed
2021

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,8 @@ exports[`getClassList 1`] = `
19141914
"end-4",
19151915
"end-auto",
19161916
"end-full",
1917+
"field-sizing-content",
1918+
"field-sizing-fixed",
19171919
"fill-current",
19181920
"fill-current/0",
19191921
"fill-current/5",

packages/tailwindcss/src/property-order.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ export default [
4242

4343
'box-sizing',
4444
'display',
45-
'aspect-ratio',
4645

46+
'field-sizing',
47+
'aspect-ratio',
4748
'height',
4849
'max-height',
4950
'min-height',

packages/tailwindcss/src/utilities.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,21 @@ test('display', async () => {
18731873
).toEqual('')
18741874
})
18751875

1876+
test('field-sizing', async () => {
1877+
expect(await run(['field-sizing-content', 'field-sizing-fixed'])).toMatchInlineSnapshot(`
1878+
".field-sizing-content {
1879+
field-sizing: content;
1880+
}
1881+
1882+
.field-sizing-fixed {
1883+
field-sizing: fixed;
1884+
}"
1885+
`)
1886+
expect(
1887+
await run(['field-sizing-[other]', '-field-sizing-content', '-field-sizing-fixed']),
1888+
).toEqual('')
1889+
})
1890+
18761891
test('aspect-ratio', async () => {
18771892
expect(await run(['aspect-video', 'aspect-[10/9]', 'aspect-4/3'])).toMatchInlineSnapshot(`
18781893
".aspect-4\\/3 {

packages/tailwindcss/src/utilities.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,12 @@ export function createUtilities(theme: Theme) {
882882
staticUtility('contents', [['display', 'contents']])
883883
staticUtility('list-item', [['display', 'list-item']])
884884

885+
/**
886+
* @css `field-sizing`
887+
*/
888+
staticUtility('field-sizing-content', [['field-sizing', 'content']])
889+
staticUtility('field-sizing-fixed', [['field-sizing', 'fixed']])
890+
885891
/**
886892
* @css `aspect-ratio`
887893
*/

0 commit comments

Comments
 (0)