Tailwind / Windi CSS compact preset for UnoCSS that provides comprehensive utility classes and theming system
—
Predefined utility combinations and common patterns for rapid development with container layout shortcuts.
Collection of shortcut definitions providing convenient utility combinations.
const shortcuts: Shortcut<Theme>[];
type Shortcut<T = {}> = StaticShortcut | DynamicShortcut<T>;
type StaticShortcut = [string, string | string[]];
type DynamicShortcut<T = {}> = [
RegExp,
(match: RegExpMatchArray, context: ShortcutContext<T>) => string | string[] | undefined,
ShortcutOptions?
];
interface ShortcutContext<T = {}> {
theme: T;
generator: UnoGenerator;
variantHandlers: VariantHandler[];
}Responsive container layout shortcuts with breakpoint support.
const containerShortcuts: Shortcut<Theme>[];Container Shortcut Pattern:
// Pattern: /^(?:(\w+)[:-])?container$/
// Generates responsive container utilities based on breakpointsGenerated Utilities:
container - Base container utility applying to all breakpointssm:container - Container starting from small breakpointmd:container - Container starting from medium breakpointlg:container - Container starting from large breakpointxl:container - Container starting from extra-large breakpoint2xl:container - Container starting from 2x extra-large breakpointBreakpoint Behavior:
When a breakpoint-specific container is used (e.g., md:container), it applies container styles starting from that breakpoint and all larger breakpoints. For example:
md:container generates: md:__container lg:__container xl:__container 2xl:__containerlg:container generates: lg:__container xl:__container 2xl:__containerContainer CSS Behavior:
The container shortcuts generate CSS that:
margin-left: auto; margin-right: auto if theme.container.center is truetheme.container.padding configurationTheme Configuration:
interface ContainerTheme {
center?: boolean;
padding?: string | Record<string, string>;
maxWidth?: Record<string, string>;
}Usage Examples:
<!-- Basic container -->
<div class="container mx-auto px-4">
<p>Centered content with responsive max-width</p>
</div>
<!-- Breakpoint-specific containers -->
<div class="md:container mx-auto">
<p>Container behavior starts at medium breakpoint</p>
</div>
<!-- Combined with other utilities -->
<div class="container lg:container mx-auto px-4 py-8">
<p>Container with padding and responsive behavior</p>
</div>Theme-based Configuration:
// UnoCSS configuration with container theme
export default defineConfig({
presets: [presetWind()],
theme: {
container: {
center: true,
padding: {
DEFAULT: '1rem',
sm: '2rem',
lg: '4rem',
xl: '5rem',
'2xl': '6rem',
},
maxWidth: {
sm: '640px',
md: '768px',
lg: '1024px',
xl: '1280px',
'2xl': '1536px',
},
},
},
});The shortcuts system processes patterns and generates corresponding utility combinations:
Internal Processing Example:
// When processing "lg:container"
// 1. Matches pattern with breakpoint "lg"
// 2. Resolves available breakpoints: ['sm', 'md', 'lg', 'xl', '2xl']
// 3. Filters to breakpoints from 'lg' onwards: ['lg', 'xl', '2xl']
// 4. Generates: ['lg:__container', 'xl:__container', '2xl:__container']
// Plus base '__container' if no breakpoint specifiedUsage Example:
import { shortcuts } from "@unocss/preset-wind";
// Shortcuts are used internally by the preset
// Access for advanced use cases or custom preset creation
const containerShortcuts = shortcuts.filter(shortcut =>
shortcut[0] instanceof RegExp && shortcut[0].source.includes('container')
);Install with Tessl CLI
npx tessl i tessl/npm-unocss--preset-wind