Setting the file. One moment.
Subchapter 10.3
references/core-layers.mdMarkdown2 KBView on GitHub
Set layer on rules:
rules: [
[/^m-(\d)$/, ([, d]) => ({ margin: `${d / 4}rem` }), { layer: 'utilities' }],
['btn', { padding: '4px' }], // default layer
]layers: {
'components': -1,
'default': 1,
'utilities': 2,
}import 'uno:components.css'
import 'uno.css'
import './my-custom.css'
import 'uno:utilities.css'outputToCssLayers: true
// Or with custom names
outputToCssLayers: {
cssLayerName: (layer) => {
if (layer === 'default') return 'utilities'
if (layer === 'shortcuts') return 'utilities.shortcuts'
}
}<!-- UnoCSS layer -->
<p class="uno-layer-my-layer:text-xl">
<!-- CSS @layer -->
<p class="layer-my-layer:text-xl">Inject raw CSS globally:
preflights: [
{
getCSS: ({ theme }) => `
* {
color: ${theme.colors.gray?.[700] ?? '#333'};
margin: 0;
}
`,
},
]With layer:
preflights: [
{
layer: 'base',
getCSS: () => `html { font-family: system-ui; }`,
},
]| Layer | Description | Order |
|---|---|---|
properties | CSS @property rules | -200 |
theme | Theme CSS variables | -150 |
base | Reset styles | -100 |