docs/presets/mini.md
The basic preset for UnoCSS, with only the most essential utilities.
::: code-group
pnpm add -D @unocss/preset-mini
yarn add -D @unocss/preset-mini
npm install -D @unocss/preset-mini
bun add -D @unocss/preset-mini
:::
import presetMini from '@unocss/preset-mini'
import { defineConfig } from 'unocss'
export default defineConfig({
presets: [
presetMini(),
// ...other presets
],
})
::: tip
This preset is included in the unocss package, you can also import it from there:
import { presetMini } from 'unocss'
:::
This preset is a subset of @unocss/preset-wind3, containing only the most essential utilities aligned with CSS's properties, but excludes opinioned or complicated utilities introduced in Tailwind CSS (container, animation, gradient etc.). This can be a good starting point for your own custom preset on top of familiar utilities from Tailwind CSS or Windi CSS.
By default, this preset generates class-based dark mode with dark: variant.
<div class="dark:bg-red:10" />
will generate:
.dark .dark\:bg-red\:10 {
background-color: rgb(248 113 113 / 0.1);
}
To instead use media query based dark mode globally you can change the config for the dark: variant:
presetMini({
dark: 'media'
})
Now
<div class="dark:bg-red:10" />
will generate:
@media (prefers-color-scheme: dark) {
.dark\:bg-red\:10 {
background-color: rgb(248 113 113 / 0.1);
}
}
CSS's native @layer is supported with variant layer-xx:
<div class="layer-foo:p4" />
<div class="layer-bar:m4" />
will generate:
@layer foo {
.layer-foo\:p4 {
padding: 1rem;
}
}
@layer bar {
.layer-bar\:m4 {
margin: 1rem;
}
}
You can fully customize your theme property in your config, and UnoCSS will eventually deeply merge it to the default theme.
:::warning
breakpoints property isn't deeply merged, but overridden, see Breakpoints.
:::
presetMini({
theme: {
// ...
colors: {
veryCool: '#0000ff', // class="text-very-cool"
brand: {
primary: 'hsl(var(--hue, 217) 78% 51%)', // class="bg-brand-primary"
}
},
}
})
class | media | DarkModeSelectorsclassThe dark mode options. It can be either class, media, or a custom selector object(DarkModeSelectors).
interface DarkModeSelectors {
/**
* Selector for light variant.
*
* @default '.light'
*/
light?: string
/**
* Selector for dark variant.
*
* @default '.dark'
*/
dark?: string
}
BooleanfalseGenerate pseudo selector as [group=""] instead of .group.
stringun-Prefix for CSS custom properties.
string | string[]undefinedUtils prefix.
boolean | on-demandtrueGenerate preflight css. It can be:
true: always generate preflight.false: no preflight.on-demand: only generate preflight for used utilities.