Tailwind / Windi CSS compact preset for UnoCSS that provides comprehensive utility classes and theming system
—
CSS transformation pipeline for handling important utilities and other post-processing tasks that modify generated CSS output.
Creates an array of postprocessors based on preset options, combining preset-mini postprocessors with Wind-specific enhancements.
/**
* Creates postprocessors array for CSS transformation pipeline
* @param options - Preset Wind configuration options
* @returns Array of postprocessor functions
*/
function postprocessors(options: PresetWindOptions): Postprocessor[];Usage Example:
import { postprocessors } from "@unocss/preset-wind";
// Create postprocessors with important handling
const processors = postprocessors({
important: true
});Handles CSS specificity control through !important declaration or selector scoping.
/**
* Creates postprocessors for handling important CSS specificity
* @param option - Important configuration (boolean, string, or undefined)
* @returns Array of postprocessor functions
*/
function important(option: PresetWindOptions['important']): Postprocessor[];Important Option Behaviors:
important: true)Adds !important to all generated CSS properties:
/* Input */
.m-4 { margin: 1rem; }
/* Output */
.m-4 { margin: 1rem !important; }important: "#app")Wraps utilities with the specified selector using :is():
/* Input */
.m-4 { margin: 1rem; }
/* Output */
#app :is(.m-4) { margin: 1rem; }Pseudo-element Handling: The selector mode correctly handles pseudo-elements:
/* Input */
.btn::before { content: ""; }
/* Output */
#app :is(.btn)::before { content: ""; }important: false or undefined)No modifications applied to CSS output:
/* Input and Output remain unchanged */
.m-4 { margin: 1rem; }Usage Examples:
import { important } from "@unocss/preset-wind";
// Boolean important mode
const booleanProcessors = important(true);
// Selector important mode
const selectorProcessors = important("#app");
// Disabled important mode
const disabledProcessors = important(false);
// Returns empty array []Postprocessors are automatically integrated into the preset pipeline:
Internal Processing Flow:
// Automatic integration in presetWind()
return {
// ... other preset properties
postprocess: postprocessors(options),
}
// Postprocessors array composition
function postprocessors(options: PresetWindOptions): Postprocessor[] {
return [
...toArray(presetMini(options).postprocess),
...important(options.important),
]
}Advanced Usage:
import { defineConfig } from "unocss";
import { presetWind, postprocessors } from "@unocss/preset-wind";
// Manual postprocessor usage (advanced)
export default defineConfig({
presets: [
{
name: 'custom-preset',
postprocess: postprocessors({
important: "#root"
})
}
],
});Each postprocessor receives a context object for CSS manipulation:
interface PostprocessorContext {
/** CSS selector being processed */
selector: string;
/** CSS property-value pairs as tuples */
entries: [string, string | number | undefined][];
/** Parent rule reference */
parent?: Rule;
/** CSS layer name */
layer?: string;
/** Sort order for CSS output */
sort?: number;
}Context Usage Example:
// Example postprocessor implementation
const customPostprocessor: Postprocessor = (util) => {
// Modify selector
if (util.selector.includes('.btn')) {
util.selector = `.custom ${util.selector}`;
}
// Modify CSS properties
util.entries.forEach(([prop, value]) => {
if (prop === 'color' && value === 'red') {
util.entries.push(['border-color', 'red']);
}
});
};Install with Tessl CLI
npx tessl i tessl/npm-unocss--preset-wind