Skip to content

Commit ca17880

Browse files
committed
docs(advance): [css-mixin] add description for embedding css with conditional
1 parent 3ee8c67 commit ca17880

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

docs/guide/advances/css-mixin.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ outline: deep
44

55
# CSS Mixin
66

7+
## Generate CSS Section
8+
79
We offer a function named `css` to generate css section and the return value can be used in styled function.
810

911
Such as:
@@ -30,7 +32,25 @@ Such as:
3032
```
3133
:::
3234

33-
# Common CSS Class
35+
## Embedded CSS with Conditional
36+
37+
```vue
38+
<script setup lang="ts">
39+
import { styled, css } from '@vvibe/vue-styled-components'
40+
41+
const testCss1 = css`
42+
background: white;
43+
`
44+
const testCss2 = css`
45+
background: blue;
46+
`
47+
const TestEmbedComponent = styled('div', { status: Boolean })`
48+
${(props) => props.status ? testCss1 : testCss2}
49+
`
50+
</script>
51+
```
52+
53+
## Using Common CSS with Class
3454

3555
You can also use `cssClass` to generate a common css class. The function will inject your css and return a class name
3656

docs/zh/guide/advances/css-mixin.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ Such as:
3030
```
3131
:::
3232

33+
## 有条件地嵌套 CSS
34+
35+
```vue
36+
<script setup lang="ts">
37+
import { styled, css } from '@vvibe/vue-styled-components'
38+
39+
const testCss1 = css`
40+
background: white;
41+
`
42+
const testCss2 = css`
43+
background: blue;
44+
`
45+
const TestEmbedComponent = styled('div', { status: Boolean })`
46+
${(props) => props.status ? testCss1 : testCss2}
47+
`
48+
</script>
49+
```
50+
3351
# 公共 CSS 类
3452

3553
你还可以使用 `cssClass` 来生成一个可公用的样式类,该函数会创建你传入的 CSS 并返回一个类名。

0 commit comments

Comments
 (0)