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
Copy file name to clipboardExpand all lines: packages/dev/s2-docs/pages/react-aria/styling.mdx
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -252,6 +252,25 @@ With this configured, all states for React Aria Components can be accessed with
252
252
</ListBoxItem>
253
253
```
254
254
255
+
## Style macro
256
+
257
+
If you want to build custom components that follow Spectrum design tokens and styling, you can use the [style macro](../s2/styling.html) from React Spectrum. The `style` macro is a build-time CSS generator that provides type safe access to Spectrum 2 design tokens including colors, spacing, sizing, and typography.
React Aria Components supports both [CSS transitions](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions) and [keyframe animations](https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes), and works with JavaScript animation libraries like [Framer Motion](https://www.framer.com/motion/).
<DisclosureTitle>I'm getting a "Could not statically evaluate macro argument" error.</DisclosureTitle>
10
+
<DisclosurePanel>
11
+
This indicates that your <code>style</code> macro has a condition that isn't evaluable at build time. This can happen for a variety of reasons such
12
+
as if you've referenced non-constant variables within your <code>style</code> macro or if you've called non-macro functions within your <code>style</code> macro.
13
+
If you are using Typescript, it can be as simple as forgetting to add <code>as const</code> to your own defined reusable macro.
14
+
</DisclosurePanel>
15
+
</Disclosure>
16
+
<DisclosureisQuiet>
17
+
<DisclosureTitle>I'm seeing a ton of duplicate rules being generated and/or my dev tools are very slow.</DisclosureTitle>
18
+
<DisclosurePanel>
19
+
Please make sure you've followed the best practices listed above.
20
+
</DisclosurePanel>
21
+
</Disclosure>
22
+
<DisclosureisQuiet>
23
+
<DisclosureTitle>I tried to pass my <code>style</code> macro to <code>UNSAFE_className</code> but it doesn't work.</DisclosureTitle>
24
+
<DisclosurePanel>
25
+
The <code>style</code> macro is not meant to be used with <code>UNSAFE_className</code>. Overrides to the Spectrum styles is highly discouraged,
26
+
consider styling an equivalent React Aria Component instead.
27
+
</DisclosurePanel>
28
+
</Disclosure>
29
+
<DisclosureisQuiet>
30
+
<DisclosureTitle>I'm coming from S1, but where are Flex/Grid/etc?</DisclosureTitle>
31
+
<DisclosurePanel>
32
+
These no longer exist. Please style <code><div></code>, <code><span></code>, and other standard HTML elements with the <code>style</code> macro instead.
0 commit comments