Preset.JS
Tailwind CSS has been designed from the ground up to be extensible and customizable, making it easy to work with and ideal for any project.
Yabe Siul tries to preserve this customization flexibility when integrating the Tailwind CSS within the WordPress. This is achieved by utilizing the preset.js
file to define the Tailwind CSS configuration.
To customize the preset.js
file, you can go to Yabe Siul → Tailwind CSS
and open the preset.js
panel.
Tailwind CSS official documentation has covered this topic in-depth. Some of them are:
Understanding the preset.js
file
Section titled Understanding the preset.js fileThe preset.js
file is a JavaScript file that lets you define the Tailwind CSS configuration.
The siul
variable
Section titled The siul variableThe siul
variable serves as the only container for the Tailwind CSS configuration. It is effectively standing in for the module.exports
in the official Tailwind CSS documentation.
The preset.js
file must have the siul
variable defined.
Wizard placeholder
Section titled Wizard placeholderWhen you use the Wizard to define customization, the generated configuration will be added to the tailwind.config.js
file at the position marked by the //-@-wizard
placeholder within the preset.js
file.
Your custom configuration
Section titled Your custom configurationThe presetConfig
variable is acted as the container for your custom configuration. It has the same structure as the siul
variable.
The presetConfig
variable in the code editor has type hinting, which allows you to view the configuration structure and available options.
Merging the configuration
Section titled Merging the configurationIn the end, the presetConfig
variable will be merged into the siul
variable.
It uses the lodash.merge
JavaScript package to merge the presetConfig
into the siul
variable.
JavaScript package
Section titled JavaScript packageThis is made possible by the esm.sh, a modern CDN that allows you to import ES6 modules from a URL.
require()
syntax
Section titled require() syntaxYabe Siul allow you to use the JavaScript package via npm within the preset.js
file for additional functionality. You can use the require()
syntax to include the JavaScript package.
The pattern for using the JavaScript package is:
The version
, path
, and query
are optional. If you don’t specify a version, the latest version will be used.
Example:
Even though it uses require()
syntax that is typically used with CommonJS modules, it is not an actual CommonJS module. It is an alias for the import()
syntax called dynamic import that is used to include a JavaScript ES6 module in modern JavaScript.
import
syntax
Section titled import syntaxYou can also use the import
syntax to include the JavaScript package from a URL.
Tailwind CSS plugins
Section titled Tailwind CSS pluginsExtending Tailwind CSS with reusable third-party plugins. Plugins allow you to expand Tailwind CSS’ capabilities by adding new styles to the user’s stylesheet via JavaScript, instead of CSS.
Yabe Siul supports the use of Tailwind CSS plugins within the preset.js
file. You can use the require()
syntax to include the Tailwind CSS plugin.