Skip to content

Commit ab7b5bc

Browse files
authored
docs(stylesheets): add usecase and SSR note to Constructible Stylesheets (#1567)
1 parent 0a44033 commit ab7b5bc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

versioned_docs/version-v4.39/components/styling.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ This approach ensures your components are adaptable and can dynamically switch b
298298

299299
## Global styles
300300

301-
While most styles are usually scoped to each component, sometimes it's useful to have styles that are available to all the components in your project. To create styles that are globally available, start by creating a global stylesheet. For example, you can create a folder in your `src` directory called `global` and create a file called `global.css` within that. Most commonly, this file is used to declare CSS custom properties on the root element via the `:root` pseudo-class. This is because styles provided via the `:root` pseudo-class can pass through the shadow boundary. For example, you can define a primary color that all your components can use.
301+
While most styles are usually scoped to each component, sometimes it's useful to have styles that are available to all the components in your project. To create styles that are globally available, start by creating a global stylesheet. For example, you can create a folder in your `src` directory called `global` and create a file called `global.css` within that. Most commonly, this file is used to declare CSS custom properties on the root element via the `:root` pseudo-class. For example, you can define a primary color that all your components can use.
302302

303303
```css
304304
:root {
@@ -371,4 +371,10 @@ The `:host()` function allows you to select the host element of a component when
371371
The `:host()` selector in global styles will only affect components that use shadow DOM. For scoped components, you should use regular tag selectors in your global styles.
372372
:::
373373

374-
This behavior can be turned off via the [`extras.addGlobalStyleToComponents`](../config/extras.md#addglobalstyletocomponents) flag.
374+
This feature enables components that use global styles to be distributed as a single component script. Since the styles are embedded, a user can import the component to a project without needing the `global.css`.
375+
376+
Constructible Stylesheets can be turned off via the [`extras.addGlobalStyleToComponents`](../config/extras.md#addglobalstyletocomponents) flag.
377+
378+
:::note
379+
When using Server Side Rendering, Constructible Stylesheets cannot be applied until components are hydrated on the client. This may cause a flash of unstyled content when the page is first displayed to the user.
380+
:::

0 commit comments

Comments
 (0)