Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Configure and use UnoCSS atomic CSS engine with presets like Wind (Tailwind-compatible), Icons, and Attributify.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/core-config.md
1---2name: unocss-configuration3description: Config file setup and all configuration options for UnoCSS4---56# UnoCSS Configuration78UnoCSS is configured via a dedicated config file in your project root.910## Config File1112**Recommended:** Use a dedicated `uno.config.ts` file for best IDE support and HMR.1314```ts15// uno.config.ts16import {17defineConfig,18presetAttributify,19presetIcons,20presetTypography,21presetWebFonts,22presetWind3,23transformerDirectives,24transformerVariantGroup25} from 'unocss'2627export default defineConfig({28shortcuts: [29// ...30],31theme: {32colors: {33// ...34}35},36presets: [37presetWind3(),38presetAttributify(),39presetIcons(),40presetTypography(),41presetWebFonts({42fonts: {43// ...44},45}),46],47transformers: [48transformerDirectives(),49transformerVariantGroup(),50],51})52```5354UnoCSS automatically looks for `uno.config.{js,ts,mjs,mts}` or `unocss.config.{js,ts,mjs,mts}` in the project root.5556## Key Configuration Options5758### rules59Define CSS utility rules. Later entries have higher priority.6061```ts62rules: [63['m-1', { margin: '0.25rem' }],64[/^m-(\d+)$/, ([, d]) => ({ margin: `${d / 4}rem` })],65]66```6768### shortcuts69Combine multiple rules into a single shorthand.7071```ts72shortcuts: {73'btn': 'py-2 px-4 font-semibold rounded-lg shadow-md',74}75```7677### theme78Theme object for design tokens shared between rules.7980```ts81theme: {82colors: {83brand: '#942192',84},85breakpoints: {86sm: '640px',87md: '768px',88},89}90```9192### presets93Predefined configurations bundling rules, variants, and themes.9495```ts96presets: [97presetWind3(),98presetIcons(),99]100```101102### transformers103Transform source code to support special syntax.104105```ts106transformers: [107transformerDirectives(),108transformerVariantGroup(),109]110```111112### variants113Preprocess selectors with ability to rewrite CSS output.114115### extractors116Handle source files and extract utility class names.117118### preflights119Inject raw CSS globally.120121### layers122Control the order of CSS layers. Default is `0`.123124```ts125layers: {126'components': -1,127'default': 1,128'utilities': 2,129}130```131132### safelist133Utilities that are always included in output.134135```ts136safelist: ['p-1', 'p-2', 'p-3']137```138139### blocklist140Utilities that are always excluded.141142```ts143blocklist: ['p-1', /^p-[2-4]$/]144```145146### content147Configure where to extract utilities from.148149```ts150content: {151pipeline: {152include: [/\.(vue|svelte|tsx|html)($|\?)/],153},154filesystem: ['src/**/*.php'],155}156```157158### separators159Variant separator characters. Default: `[':', '-']`160161### outputToCssLayers162Output UnoCSS layers as CSS Cascade Layers.163164```ts165outputToCssLayers: true166```167168## Specifying Config File Location169170```ts171// vite.config.ts172import UnoCSS from 'unocss/vite'173174export default defineConfig({175plugins: [176UnoCSS({177configFile: '../my-uno.config.ts',178}),179],180})181```182183<!--184Source references:185- https://unocss.dev/guide/config-file186- https://unocss.dev/config/187-->188