Skip to content

Commit 19d3ad7

Browse files
committed
feat: configuring UnoCSS
1 parent d29625c commit 19d3ad7

File tree

11 files changed

+70
-10
lines changed

11 files changed

+70
-10
lines changed

.vitepress/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ const Customizations = [
148148
text: 'Configure Vite',
149149
link: '/custom/config-vite',
150150
},
151+
{
152+
text: 'Configure UnoCSS',
153+
link: '/custom/config-unocss',
154+
},
151155
{
152156
text: 'Configure Windi CSS',
153157
link: '/custom/config-windicss',

addons/write-an-addon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ An addon can contribute to the following points:
99
- Global styles (use with caution has it is more the role of [themes](/themes/use))
1010
- Provide custom layouts or override the existing one
1111
- Provide custom components or override the existing one
12-
- Extend Windi CSS configurations
12+
- Extend UnoCSS/Windi CSS configurations
1313
- Configure tools like Monaco and Prism
1414

1515
## Conventions

custom/config-unocss.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Configure UnoCSS
2+
3+
<Environment type="node" />
4+
5+
[UnoCSS](https://unocss.dev) is now the default CSS framework for Slidev since v0.42.0. UnoCSS is an fast atomic CSS engine that has full flexibility and extensibility.
6+
7+
By default, Slidev enables the following presets out-of-box:
8+
9+
- [@unocss/preset-uno](https://unocss.dev/presets/uno) - Tailwind / Windi CSS compatible utilities
10+
- [@unocss/preset-attributify](https://unocss.dev/presets/attributify) - Attributify mode
11+
- [@unocss/preset-icons](https://unocss.dev/presets/icons) - Use any icons as class
12+
- [@unocss/preset-web-fonts](https://unocss.dev/presets/web-fonts) - Use web fonts at ease
13+
- [@unocss/transformer-directives](https://unocss.dev/transformers/directives) - Use `@apply` in CSS
14+
15+
You can therefore style your content the way you want. For example:
16+
17+
```html
18+
<div class="grid pt-4 gap-4 grid-cols-[100px,1fr]">
19+
20+
### Name
21+
22+
- Item 1
23+
- Item 2
24+
25+
</div>
26+
```
27+
28+
## Configurations
29+
30+
You can create `uno.config.ts` under the root of your project to extend the builtin configurations
31+
32+
```ts
33+
import { defineConfig } from 'unocss'
34+
35+
export default defineConfig({
36+
shortcuts: {
37+
// custom the default background
38+
'bg-main': 'bg-white text-[#181818] dark:(bg-[#121212] text-[#ddd])',
39+
},
40+
// ...
41+
})
42+
```
43+
44+
Learn more about [UnoCSS configurations](https://unocss.dev/guide/config-file)

custom/config-windicss.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22

33
<Environment type="node" />
44

5-
Markdown naturally supports embedded HTML markups. You can therefore style your content the way you want. To provide some convenience, we have [Windi CSS](https://github.com/windicss/windicss) built-in, so you can style markup directly using class utilities.
5+
::: warning
6+
Since Slidev v0.42.0, [UnoCSS](/custom/config-unocss) become the default CSS framework for Slidev.
7+
8+
You can still use Windi CSS by setting `css: windicss` in the frontmatter.
9+
```md
10+
---
11+
css: windicss
12+
---
13+
```
14+
:::
15+
16+
Markdown naturally supports embedded HTML markups. You can therefore style your content the way you want.
617

718
For example:
819

custom/directory-structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ import './code.css'
115115
import './layouts.css'
116116
```
117117

118-
Styles will be processed by [Windi CSS](https://windicss.org/) and [PostCSS](https://postcss.org/), so you can use css nesting and [at-directives](https://windicss.org/features/directives.html) out-of-box. For example:
118+
Styles will be processed by [UnoCSS](https://unocss.dev/) and [PostCSS](https://postcss.org/), so you can use css nesting and [at-directives](https://windicss.org/features/directives.html) out-of-box. For example:
119119

120120
```less
121121
.slidev-layout {

custom/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Customizations
22

3-
Slidev is fully customizable, from styling to tooling configurations. It allows you to configure the tools underneath ([Vite](/custom/config-vite), [Windi CSS](/custom/config-windicss), [Monaco](/custom/config-monaco), etc.)
3+
Slidev is fully customizable, from styling to tooling configurations. It allows you to configure the tools underneath ([Vite](/custom/config-vite), [UnoCSS](/custom/config-unocss), [Monaco](/custom/config-monaco), etc.)
44

55
## Frontmatter Configures
66

@@ -118,6 +118,7 @@ Refer to the [Directory Structure](/custom/directory-structure) section.
118118
- [Highlighters](/custom/highlighters)
119119
- [Configure Vue](/custom/config-vue)
120120
- [Configure Vite](/custom/config-vite)
121+
- [Configure UnoCSS](/custom/config-unocss)
121122
- [Configure Windi CSS](/custom/config-windicss)
122123
- [Configure Monaco](/custom/config-monaco)
123124
- [Configure KaTeX](/custom/config-katex)

guide/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Since Slidev is based on the Web, you can apply any grid layouts as you want. [CSS Grids](https://css-tricks.com/snippets/css/complete-guide-grid/), [flexboxes](https://css-tricks.com/snippets/css/a-guide-to-flexbox/), or even [Masonry](https://css-tricks.com/native-css-masonry-layout-in-css-grid/), you get the full controls.
66

7-
Since we have [Windi CSS](https://windicss.org/) built-in, here is one simple way for you to reference:
7+
Since we have [UnoCSS](https://windicss.org/) built-in, here is one simple way for you to reference:
88

99
```html
1010
<div class="grid grid-cols-2 gap-4">

guide/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You can learn more about the rationale behind the project in the [Why Slidev](/g
1313
- 📝 [**Markdown-based**](/guide/syntax.html) - use your favorite editors and workflow
1414
- 🧑‍💻 [**Developer Friendly**](/guide/syntax.html#code-blocks) - built-in syntax highlighting, live coding, etc.
1515
- 🎨 [**Themable**](/themes/gallery.html) - theme can be shared and used with npm packages
16-
- 🌈 [**Stylish**](/guide/syntax.html#embedded-styles) - on-demand utilities via [Windi CSS](https://windicss.org/) or [UnoCSS](https://github.com/unocss/unocss).
16+
- 🌈 [**Stylish**](/guide/syntax.html#embedded-styles) - on-demand utilities via [UnoCSS](https://github.com/unocss/unocss) or [Windi CSS](https://windicss.org/).
1717
- 🤹 [**Interactive**](/custom/directory-structure.html#components) - embedding Vue components seamlessly
1818
- 🎙 [**Presenter Mode**](/guide/presenter-mode.html) - use another window, or even your phone to control your slides
1919
- 🎨 [**Drawing**](/guide/drawing.html) - draw and annotate on your slides

guide/syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Slides are written within **a single markdown file** (by default `./slides.md`).
44

5-
You can use [the Markdown features](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) as you normally would, with the additional support of inlined HTML and Vue Components. Styling using [Windi CSS](https://windicss.org) is also supported. Use `---` padded with a new line to separate your slides.
5+
You can use [the Markdown features](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) as you normally would, with the additional support of inlined HTML and Vue Components. Styling using [UnoCSS](/custom/config-unocss) is also supported. Use `---` padded with a new line to separate your slides.
66

77
~~~md
88
# Slidev
@@ -185,7 +185,7 @@ h1 {
185185

186186
`<style>` tag in Markdown is always [scoped](https://vuejs.org/api/sfc-css-features.html#scoped-css). As an outstanding result, a selector with the child combinator (`.a > .b`) is unusable as such; see the previous link. To have global style overrides, check out the [customization section](/custom/directory-structure#style).
187187

188-
Powered by [Windi CSS](https://windicss.org), you can directly use nested css and [directives](https://windicss.org/features/directives.html) (e.g. `@apply`)
188+
Powered by [UnoCSS](/custom/config-unocss), you can directly use nested css and [directives](https://windicss.org/features/directives.html) (e.g. `@apply`)
189189

190190
```md
191191
# Slidev

guide/why.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Learn more about [highlighters](/custom/highlighters) and [Monaco configuration]
3232

3333
## Fast
3434

35-
Slidev is powered by [Vite](https://vitejs.dev/), [Vue 3](https://v3.vuejs.org/) and [Windi CSS](https://windicss.org/), which give you the most wonderful authoring experience. Every change you made will reflect to your slides **instantly**.
35+
Slidev is powered by [Vite](https://vitejs.dev/), [Vue 3](https://v3.vuejs.org/) and [UnoCSS](https://unocss.dev/), which give you the most wonderful authoring experience. Every change you made will reflect to your slides **instantly**.
3636

3737
Find more about [our tech stack](/guide/#tech-stack).
3838

0 commit comments

Comments
 (0)