Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Tailwind JIT

74 sites Security covered
View on drupal.org

This module provides Just-in-Time (JIT) compilation for Tailwind CSS in Drupal themes. It dynamically generates minimized CSS based on the styles actually used on each page, resulting in highly optimized stylesheets. The module automatically detects CSS classes from rendered HTML and can be configured to use an executable path for Tailwind CSS.

Provides Just-in-Time compilation of Tailwind CSS for Drupal themes.

Setup

  1. Install and enable the module
  2. Install Tailwind CSS
  3. In your settings.php, create a variable named $settings['tailwind_jit_executable'], containing the path to the Tailwind executable:
    • If you installed the standalone CLI build, the path depends on the location to your downloaded binary and your OS:
      You must either provide an absolute path like
      $settings['tailwind_jit_executable'] = '/usr/bin/tailwindcss-macos-arm64';
      or a path relative to the DRUPAL_ROOT directory (usually /web), e.g.
      $settings['tailwind_jit_executable'] = '../vendor/bin/tailwindcss';
    • If you installed the NodeJS version, the path most likely will be
      $settings['tailwind_jit_executable'] = 'npx tailwindcss';
  4. Go to the theme settings and activate the compiler:
    Appearance => Settings (of your theme) => Section "Tailwind CSS Just-in-time compilation"

Now when you visit your website, the uncompiled CSS input file will be dynamically replaced with a minified Tailwind CSS output. Only those styles that are actually used on a page are included in the output. The result is a perfectly minimized CSS for every single page of your website.

This module can not generate styles for blocks rendered by core's BigPipe module. It is recommended to disable BigPipe if you want to use this module.

FAQ

  • Can I use arbitrary values like pt-[1.2345rem]?
    Yes.
  • Does it work with Views paging or Ajax requests?
    Yes.
  • Can I use it with Layout builder or Paragraphs module?
    Yes, CSS classes rendered by Twig templates will be detected automatically. With the help of an extra module that provides an UI to inject CSS classes (like e.g. Block class or Layout builder styles or Style options module) site builders can even style them on the fly in the admin UI .
  • Can I use it with admin themes?
    Yes. I recommend the Field group module to easily finetune your UI without creating your own subtheme and without any custom code.
    Want two input fields in one line? Create a field group with those two fields below and inject grid grid-cols-2 on the parent container in the node form display.
  • Is the compiled CSS cached?
    Yes. The best performance is achieved if core's "Internal Page Cache" module is enabled and used. If Internal page cache is not applicable, Tailwind JIT itself can optionally cache the compiled CSS in the database.
  • Where do I put my tailwind.config.js and how do I configure the template file paths (the content: [] in the config file)?
    You don't need a tailwind.config.js, the module will automatically provide the current page's HTML as content to the compiler. If you need to add additional custom config, use Tailwind's @config directive inside your input CSS file.
    Note: If you use a custom config file, the content key will be ignored, this key will always be set by the module.
  • Can I use multiple CSS input files or separate input files for individual Drupal libraries?
    No, not by library. By concept Tailwind CSS is designed to work with one CSS input file and will automatically create a purged, minimized CSS depending on page content. But is is possible to define a separate input file for Ajax requests, e.g. one without Tailwind's preflight styles.

Activity

Total releases
1
First release
Mar 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Release date
1.2.0 Stable Mar 10, 2025