You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Below we have two components: <strong>HelloWorld</strong> and <strong>FooBar</strong>.</p>
18
-
<p>Both of these components have <strong>locally scoped CSS</strong> that inherit from a common set of CSS Modules.</p>
19
-
<p>Since CSS Modules can be composed, the resulting markup is optimised by <b>reusing classes between components</b>.</p>
15
+
<h2>Scoped Selectors</h2>
16
+
<p>In CSS Modules, selectors are scoped by default.</p>
17
+
<p>The following component uses two classes, <strong>.root</strong> and <strong>.text</strong>, both of which would typically be too vague in a larger project.</p>
18
+
<p>CSS Module semantics ensure that these <strong>classes are locally scoped</strong> to the component and don't collide with other classes in the global scope.</p>
19
+
<ScopedSelectors/>
20
20
21
-
<HelloWorld/>
22
-
<br/>
23
-
<FooBar/>
21
+
<h2>Class Inheritance</h2>
22
+
<p>Both of the components below have <strong>locally scoped CSS</strong> that <strong>inherits from a common set of CSS Modules.</strong></p>
23
+
<p>Since CSS Modules can be composed, the resulting markup is optimised by <b>reusing classes between components</b>.</p>
24
+
<ClassInheritance/>
24
25
26
+
<h2>Inheritance Overrides</h2>
25
27
<p>When extending classes, <strong>inherited style properties can be overridden</strong> as you'd expect.</p>
26
28
<p>The following component extends two different classes, but provides overrides which then take precedence.</p>
27
29
<InheritanceOverrides/>
28
30
29
-
<p>CSS Modules even provide <strong>locally scoped animations</strong>, which are typically defined in the global scope.</p>
30
-
<p>The following <strong>BouncingBall</strong> component extends a <strong>".bounce"</strong> class from a separate animations module.</p>
31
-
<p>The <strong>"bounce"</strong> keyframes are private to the animations module, only exposed via the <strong>".bounce"</strong> class to those that either extend from it or import it.</p>
31
+
<h2>Scoped Animations</h2>
32
32
33
-
<BouncingBall/>
33
+
<p>CSS Modules even provide <strong>locally scoped animations</strong>, which are typically defined in the global scope.</p>
34
+
<p>The animation's keyframes are private to the animations module, only exposed publicly via a class which this component inherits from.</p>
0 commit comments