File tree Expand file tree Collapse file tree 1 file changed +40
-2
lines changed
Expand file tree Collapse file tree 1 file changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ npm install --save-dev svelte-preprocess-cssmodules
2727
2828## Usage
2929
30- Add ` module ` attribute to the ` <style> ` tag to enable cssModules in the component.
30+ Add the ` module ` attribute to the ` <style> ` tag to enable cssModules
3131
3232``` html
3333<style module >
@@ -213,6 +213,44 @@ Force a selector to be scoped within a component to prevent style inheritance on
213213<p class =" child-uhRt2j" >My <em >secondary</em > lorem <strong >ipsum tuye</strong ></p >
214214```
215215
216+ When used with a class, ` :local() ` applies the svelte scoping system to the selector. This could be useful when targetting global classname.
217+
218+ ``` html
219+ <style module >
220+ .actions {
221+ padding : 10px ;
222+ }
223+ /* target a css framework classname without replacing it*/
224+ :local(.btn-primary ) {
225+ margin-right : 10px ;
226+ }
227+ </style >
228+
229+ <div class =" actions" >
230+ <button class =" btn btn-primary" >Ok</button >
231+ <button class =" btn btn-default" >Cancel</button >
232+ </div >
233+ ```
234+
235+ * Generating*
236+
237+ ``` html
238+ <style >
239+ .actions-7Fhti9 {
240+ padding : 10px ;
241+ }
242+ .btn-primary.svelte-saq8ts {
243+ margin-right : 10px ;
244+ }
245+ </style >
246+
247+ <div class =" actions-7Fhti9" >
248+ <button class =" btn btn-primary svelte-saq8ts" >Ok</button >
249+ <button class =" btn btn-default" >Cancel</button >
250+ </div >
251+ ```
252+
253+
216254## Import styles from an external stylesheet
217255
218256Alternatively, styles can be created into an external file and imported onto a svelte component from the ` <script> ` tag. The name referring to the import can then be used in the markup targetting any existing classname of the stylesheet.
@@ -763,7 +801,7 @@ export default {
763801</section >
764802```
765803
766- *** OR** Svelte Component using ` import ` *
804+ *** OR** Svelte Component importing external stylesheet *
767805
768806``` css
769807/* * style.module.css */
You can’t perform that action at this time.
0 commit comments