@@ -21,7 +21,7 @@ Generate CSS Modules classname on Svelte components
2121 - [ Destructuring import] ( #destructuring-import )
2222 - [ kebab-case situation] ( #kebab-case-situation )
2323 - [ Unnamed import] ( #unnamed-import )
24- - [ Avoid class directive ] ( #avoid-class-directive )
24+ - [ Directive and dynamic classes ] ( #directive-and-dynamic-classes )
2525- [ Code example] ( #code-example )
2626- [ Why CSS Modules on Svelte] ( #why-css-modules-on-svelte )
2727
@@ -505,8 +505,10 @@ p { font-size: 18px; }
505505<p class =" svelte-vg78j0" >My error message</p >
506506```
507507
508- ### Avoid class directive
509- The Svelte's builtin ` class: ` directive is ** not working** with import cssModules because they are dynamics. ** Use JS syntax instead**
508+ ### Directive and Dynamic classes
509+
510+ Use the Svelte's builtin ` class: ` directive or javascript template to display a class dynamically.
511+ ** Note** : the * shorthand directive* is ** NOT working** with CSS Modules.
510512
511513``` html
512514<script >
@@ -518,13 +520,15 @@ The Svelte's builtin `class:` directive is **not working** with import cssModule
518520
519521<button on:click ={() => isSuccess = !isSuccess}>Toggle</button >
520522
521- <!-- NOT WORKING -->
522- <p class:success = {isSuccess} class:error = {!isSuccess} >Notice </p >
523+ <!-- Error -->
524+ <p class:success >Success </p >
523525
524- <!-- OK -->
525- <p class ={notice} >Notice</p >
526+ <!-- Ok -->
527+ <p
528+ class:success ={isSuccess}
529+ class:error ={!isSuccess} >Notice</p >
526530
527- <!-- OK -- >
531+ <p class = {notice} >Notice</ p >
528532<p class ={isSuccess ? success : error} >Notice</p >
529533```
530534
0 commit comments