tailwindcss/packages
Adam Wathan 45fb21e753
Add support for the theme() function in the plugin API (#14207)
This PR adds support for the [`theme()`
function](https://tailwindcss.com/docs/plugins#dynamic-utilities) from
the v3 plugin API, used for configuring which values functional
utilities support:

```js
plugin(function({ matchUtilities, theme }) {
  matchUtilities(
    {
      tab: (value) => ({
        tabSize: value
      }),
    },
    { values: theme('tabSize') }
  )
})
```

Things this handles:

- "Upgrading" theme keys to their v4 names, so if you do
`theme('colors')` that will correctly retrieve all the colors from the
`--color-*` namespace with the new CSS variable based configuration
- Polyfilling dependent keys, so `theme('backgroundColor')` will still
pull everything in `--color-*` even though there is no values in the
`backgroundColor` namespace in v4 by default
- Polyfilling theme values that are now handled by "bare values"
internally, so even though there is no `flexShrink` theme values in v4,
`theme('flexShrink')` will still configure your plugin to properly
support any value that the built-in `shrink-*` utilities support

Things that aren't handled:

- Theme values that have been replaced by static utilities can't be
retrieved yet, so for example `theme('cursor')` returns nothing right
now because there are no values for the `cursor-*` utilities in the
theme anymore, they are all just baked in to the framework.

This will be handled in a future PR.

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2024-08-20 11:05:08 -04:00
..
@tailwindcss-cli Improve Oxide scanner API (#14187) 2024-08-16 15:05:42 +02:00
@tailwindcss-postcss Improve Oxide scanner API (#14187) 2024-08-16 15:05:42 +02:00
@tailwindcss-vite Improve Oxide scanner API (#14187) 2024-08-16 15:05:42 +02:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
internal-postcss-fix-relative-paths Bump dependencies (#14160) 2024-08-09 16:12:24 +02:00
tailwindcss Add support for the theme() function in the plugin API (#14207) 2024-08-20 11:05:08 -04:00
tsconfig.base.json introduce v4 codebase 2024-03-05 14:29:15 +01:00