Skip to content

Commit

Permalink
docs: add section about using preflight (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
chu121su12 committed Jun 6, 2022
1 parent e8abeeb commit e66cb72
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Expand Up @@ -391,6 +391,26 @@ import '@unocss/reset/tailwind.css'

Learn more at [@unocss/reset](https://github.com/unocss/unocss/tree/main/packages/reset).

### Preflight

You can inject raw css as preflights from the configuration. The resolved `theme` is available to customize the css.

<!--eslint-skip-->

```ts
preflights: [
{
getCss: ({ theme }) => `
* {
color: ${theme.colors.gray?.[700] ?? '#333'}
padding: 0;
margin: 0;
}
`
}
]
```

### Custom Variants

[Variants](https://windicss.org/utilities/general/variants.html) allows you to apply some variations to your existing rules. For example, to implement the `hover:` variant from Tailwind:
Expand Down Expand Up @@ -493,6 +513,17 @@ This will generate:
.m-2 { margin: 0.5rem; }
```

Layering also can be set on each preflight:

```ts
preflights: [
{
layer: 'my-layer',
getCss: async () => (await fetch('my-style.css')).text(),
},
]
```

You can control the order of layers by:

<!--eslint-skip-->
Expand Down

0 comments on commit e66cb72

Please sign in to comment.