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
Replaced em-dashes across docs prose with colons, semicolons, periods,
or parentheses per the project rule. Dropped the literal em-dash glyph
from the blog byline divider in favor of a middle dot.
Fixed three Nav components that pixel sizes through `rem()`; nav and
sidebar widths use plain px from `utils/sizes.ts`.
`utils/blog.server.ts` now loads MDX modules concurrently via
`Promise.all`. `utils/cssCompatFormats.ts` deduplicates a double sort.
`Nav/SidebarMenus.tsx` hoists `activeHref(pathname)` out of its top-level
`.map` so the lookup runs once per render instead of per item.
Removed two unused exports: `searchModalWidth` in `utils/sizes.ts`
and the precomputed `Author.websiteHost` in `utils/authors.ts`.
Standard `eslint-plugin-jsx-a11y` does not recognize styled-components — it only inspects JSX element names and cannot determine that `<StyledButton>` is a `<button>`. Use [`eslint-plugin-styled-components-a11y`](https://www.npmjs.com/package/eslint-plugin-styled-components-a11y) instead, which parses styled-components' tagged template literals to identify the underlying HTML element.
54
+
Standard `eslint-plugin-jsx-a11y` does not recognize styled-components: it only inspects JSX element names and cannot determine that `<StyledButton>` is a `<button>`. Use [`eslint-plugin-styled-components-a11y`](https://www.npmjs.com/package/eslint-plugin-styled-components-a11y) instead, which parses styled-components' tagged template literals to identify the underlying HTML element.
@@ -71,7 +71,7 @@ The plugin mirrors `eslint-plugin-jsx-a11y` for styled components, including rul
71
71
72
72
### Runtime auditing
73
73
74
-
For runtime accessibility checks, use [`@axe-core/react`](https://www.npmjs.com/package/@axe-core/react) in development. It audits the rendered DOM and logs violations to the browser console — it works with any styling approach since it inspects the final HTML:
74
+
For runtime accessibility checks, use [`@axe-core/react`](https://www.npmjs.com/package/@axe-core/react) in development. It audits the rendered DOM and logs violations to the browser console; it works with any styling approach since it inspects the final HTML:
Every unique interpolation result generates a new CSS class. For values that change frequently (colors from a picker, positions from mouse events, animation progress), this can produce hundreds of classes. styled-components warns at 200+.
24
24
25
-
CSS custom properties avoid this entirely — the CSS rule stays the same and the browser updates the variable natively:
25
+
CSS custom properties avoid this entirely: the CSS rule stays the same and the browser updates the variable natively.
26
26
27
27
```tsx
28
28
// Bad: new CSS class for every distinct color
@@ -40,7 +40,7 @@ const Box = styled.div`
40
40
41
41
### Use `attrs` for rapidly-changing values
42
42
43
-
When a value changes on every frame (mouse position, scroll offset), use `attrs` with a `style` object. This applies values as inline styles — no class generation at all:
43
+
When a value changes on every frame (mouse position, scroll offset), use `attrs` with a `style` object. This applies values as inline styles, no class generation at all.
44
44
45
45
```tsx
46
46
// Bad: generates a new CSS class on every mouse move
Copy file name to clipboardExpand all lines: sections/advanced/security.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ You can use [`CSS.escape`](https://developer.mozilla.org/en-US/docs/Web/API/CSS/
26
26
27
27
If your site sets a [`style-src` CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src) that requires a `nonce`, styled-components will attach it to every injected `<style>` tag. You can supply the nonce in any of the following ways (first match wins):
28
28
29
-
1. Pass `nonce` explicitly to [`StyleSheetManager`](/docs/api#stylesheetmanager) — the recommended approach for Next.js, Remix, and other frameworks where the nonce is generated per-request:
29
+
1. Pass `nonce` explicitly to [`StyleSheetManager`](/docs/api#stylesheetmanager): the recommended approach for Next.js, Remix, and other frameworks where the nonce is generated per-request.
Copy file name to clipboardExpand all lines: sections/advanced/server-side-rendering.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Key behaviors in RSC:
16
16
17
17
- No `'use client'` directive required
18
18
-`ThemeProvider` becomes a pass-through component (no context in RSC)
19
-
-`StyleSheetManager` works in RSC as of v6.4 — `stylisPlugins`, `shouldForwardProp`, and `nonce` are applied
19
+
-`StyleSheetManager` works in RSC as of v6.4 (`stylisPlugins`, `shouldForwardProp`, and `nonce` are applied)
20
20
- CSS is automatically injected inline via `<style>` tags
21
21
22
22
Best practices for RSC:
@@ -30,7 +30,7 @@ Best practices for RSC:
30
30
31
31
#### Child-index selector caveat
32
32
33
-
RSC emits inline `<style>` tags as siblings of your styled elements. These tags are real DOM children, so `:first-child`, `:last-child`, and `:nth-child()` count them — shifting indices and breaking your styles. Use `:first-of-type` / `:nth-of-type()` instead, which filter by element type and are immune to this issue.
33
+
RSC emits inline `<style>` tags as siblings of your styled elements. These tags are real DOM children, so `:first-child`, `:last-child`, and `:nth-child()` count them, shifting indices and breaking your styles. Use `:first-of-type` / `:nth-of-type()` instead, which filter by element type and are immune to this issue.
34
34
35
35
If you need `:nth-child()` specifically, use the built-in [`stylisPluginRSC`](/docs/api#stylesheetmanager) plugin (v6.4+) which rewrites these selectors to exclude styled-components style tags:
This uses CSS Selectors Level 4 `of S` syntax ([browser support](https://caniuse.com/css-nth-child-of-s): Chrome 111+, Firefox 113+, Safari 9+). In unsupported browsers, the entire CSS rule is dropped — so only opt in if your audience supports it.
46
+
This uses CSS Selectors Level 4 `of S` syntax ([browser support](https://caniuse.com/css-nth-child-of-s): Chrome 111+, Firefox 113+, Safari 9+). In unsupported browsers, the entire CSS rule is dropped, so only opt in if your audience supports it.
47
47
48
48
#### Theming with CSS custom properties
49
49
@@ -62,7 +62,7 @@ const Button = styled.button`
62
62
`;
63
63
```
64
64
65
-
Or set variables manually on a parent element — they cascade to all DOM children:
65
+
Or set variables manually on a parent element. They cascade to all DOM children:
66
66
67
67
```tsx
68
68
const Container =styled.div``;
@@ -81,7 +81,7 @@ To ensure deterministic component IDs for server/client consistency, use our [Ba
81
81
82
82
> If you use React Server Components (v6.3+), the plugins are optional for SSR but still provide minification and more legible class names in DevTools.
83
83
84
-
For Next.js users, the SWC plugin is built-in — just add `styledComponents: true` to your `next.config.js` compiler options.
84
+
For Next.js users, the SWC plugin is built-in; just add `styledComponents: true` to your `next.config.js` compiler options.
0 commit comments