Skip to content

Commit

Permalink
Add field-sizing utilities (#14469)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
thecrypticace and adamwathan authored Sep 20, 2024
1 parent 36fb123 commit fe2610e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support `screens` in JS config files ([#14415](https://github.com/tailwindlabs/tailwindcss/pull/14415))
- Add `bg-radial-*` and `bg-conic-*` utilities for radial and conic gradients ([#14467](https://github.com/tailwindlabs/tailwindcss/pull/14467))
- Add new `shadow-initial` and `inset-shadow-initial` utilities for resetting shadow colors ([#14468](https://github.com/tailwindlabs/tailwindcss/pull/14468))
- Add `field-sizing-*` utilities ([#14469](https://github.com/tailwindlabs/tailwindcss/pull/14469))

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,8 @@ exports[`getClassList 1`] = `
"end-4",
"end-auto",
"end-full",
"field-sizing-content",
"field-sizing-fixed",
"fill-current",
"fill-current/0",
"fill-current/5",
Expand Down
3 changes: 2 additions & 1 deletion packages/tailwindcss/src/property-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ export default [

'box-sizing',
'display',
'aspect-ratio',

'field-sizing',
'aspect-ratio',
'height',
'max-height',
'min-height',
Expand Down
15 changes: 15 additions & 0 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,21 @@ test('display', async () => {
).toEqual('')
})

test('field-sizing', async () => {
expect(await run(['field-sizing-content', 'field-sizing-fixed'])).toMatchInlineSnapshot(`
".field-sizing-content {
field-sizing: content;
}
.field-sizing-fixed {
field-sizing: fixed;
}"
`)
expect(
await run(['field-sizing-[other]', '-field-sizing-content', '-field-sizing-fixed']),
).toEqual('')
})

test('aspect-ratio', async () => {
expect(await run(['aspect-video', 'aspect-[10/9]', 'aspect-4/3'])).toMatchInlineSnapshot(`
".aspect-4\\/3 {
Expand Down
6 changes: 6 additions & 0 deletions packages/tailwindcss/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,12 @@ export function createUtilities(theme: Theme) {
staticUtility('contents', [['display', 'contents']])
staticUtility('list-item', [['display', 'list-item']])

/**
* @css `field-sizing`
*/
staticUtility('field-sizing-content', [['field-sizing', 'content']])
staticUtility('field-sizing-fixed', [['field-sizing', 'fixed']])

/**
* @css `aspect-ratio`
*/
Expand Down

0 comments on commit fe2610e

Please sign in to comment.