No description
Find a file
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
.github Bump GitHub actions to latest version (#14182) 2024-08-13 18:12:19 +02:00
crates Improve Oxide scanner API (#14187) 2024-08-16 15:05:42 +02:00
integrations Add Next.js integration test (#14163) 2024-08-16 15:45:52 +02:00
packages Add support for the theme() function in the plugin API (#14207) 2024-08-20 11:05:08 -04:00
playgrounds Bump dependencies (#14160) 2024-08-09 16:12:24 +02:00
scripts Add @source support (#14078) 2024-08-07 16:38:44 +02:00
.gitignore Add test.debug to integration tests (#14133) 2024-08-08 12:02:19 +02:00
.npmrc introduce v4 codebase 2024-03-05 14:29:15 +01:00
.prettierignore Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
Cargo.lock Improve Oxide scanner API (#14187) 2024-08-16 15:05:42 +02:00
Cargo.toml Hoist oxide/crates to just crates (#13333) 2024-03-23 09:00:48 -04:00
CHANGELOG.md Add support for the theme() function in the plugin API (#14207) 2024-08-20 11:05:08 -04:00
LICENSE Add README, LICENSE, and CONTRIBUTING (#13088) 2024-03-05 14:45:39 -05:00
package.json Fix v4 release workflow (#14167) 2024-08-09 19:57:16 +02:00
pnpm-lock.yaml Bump dependencies (#14160) 2024-08-09 16:12:24 +02:00
pnpm-workspace.yaml Bump dependencies (#14160) 2024-08-09 16:12:24 +02:00
README.md Copy README file to every package (#13096) 2024-03-06 08:49:31 -05:00
turbo.json Fix Rust build by passing through RUSTUP_HOME variable (#14171) 2024-08-12 11:37:45 +02:00
vitest.workspace.ts introduce v4 codebase 2024-03-05 14:29:15 +01:00

Tailwind CSS

A utility-first CSS framework for rapidly building custom user interfaces.

Build Status Total Downloads Latest Release License


Documentation

For full documentation, visit tailwindcss.com.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss Tailwind CSS on GitHub

For chatting with others using the framework:

Join the Tailwind CSS Discord Server

Contributing

If you're interested in contributing to Tailwind CSS, please read our contributing docs before submitting a pull request.