Skip to content

Commit 6575898

Browse files
docs: add useCssModule (#833)
1 parent e7c380d commit 6575898

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/api/global-api.md

+44
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,47 @@ export default {
474474
}
475475
}
476476
```
477+
478+
## useCssModule
479+
480+
:::warning
481+
`useCssModule` can only be used within `render` or `setup` functions.
482+
:::
483+
484+
Allows CSS modules to be accessed within the [`setup`](/api/composition-api.html#setup) function of a [single-file component](/guide/single-file-component.html):
485+
486+
```vue
487+
<script>
488+
import { h, useCssModule } from 'vue'
489+
490+
export default {
491+
setup () {
492+
const style = useCssModule()
493+
494+
return () => h('div', {
495+
class: style.success
496+
}, 'Task complete!')
497+
}
498+
}
499+
</script>
500+
501+
<style module>
502+
.success {
503+
color: #090;
504+
}
505+
</style>
506+
```
507+
508+
For more information about using CSS modules, see [Vue Loader - CSS Modules](https://vue-loader.vuejs.org/guide/css-modules.html).
509+
510+
### Arguments
511+
512+
Accepts one argument: `name`
513+
514+
#### name
515+
516+
- **Type:** `String`
517+
518+
- **Details:**
519+
520+
The name of the CSS module. Defaults to `'$style'`.

0 commit comments

Comments
 (0)