Skip to content

Commit 0c6ac3f

Browse files
committed
review comments
1 parent 807beb0 commit 0c6ac3f

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

packages/dev/s2-docs/pages/s2/styling.mdx

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,6 @@ import {Button} from '@react-spectrum/s2';
9999
'visibility'
100100
]} />
101101

102-
### UNSAFE Style Overrides
103-
104-
We highly discourage overriding the styles of React Spectrum components because it may break at any time when we change our implementation, making it difficult for you to update in the future. Consider using [React Aria Components](https://react-spectrum.adobe.com/react-aria/) with our `style` macro to build a custom component with Spectrum styles instead.
105-
106-
With that being said, the `UNSAFE_className` and `UNSAFE_style` props are supported on Spectrum 2 components as last-resort escape hatches.
107-
108-
```tsx
109-
/* YourComponent.tsx */
110-
import {Button} from '@react-spectrum/s2';
111-
import './YourComponent.css';
112-
113-
function YourComponent() {
114-
return <Button UNSAFE_className="your-unsafe-class">Button</Button>;
115-
}
116-
```
117-
118-
```css
119-
/* YourComponent.css */
120-
.your-unsafe-class {
121-
background: red;
122-
}
123-
```
124-
125102
## Values
126103

127104
The `style` macro supports a constrained set of values per property that conform to Spectrum 2. This improves consistency and maintainability. See the [reference](./styling/reference.html) page for a full list of available style macro properties.
@@ -148,6 +125,7 @@ Size props like `width` and `height` accept arbitrary pixel values. Values are c
148125
### Typography
149126

150127
Spectrum 2 typography is applied via the `font` shorthand, which sets `fontFamily`, `fontSize`, `fontWeight`, `lineHeight`, and `color`. You can override any of these individually.
128+
Note that you should always specify the `font` at the element level, setting it globally is insufficient since this will often differ per component.
151129

152130
```tsx
153131
<main>
@@ -170,6 +148,10 @@ Type scales include: UI, Body, Heading, Title, Detail, and Code. Each scale has
170148
</Content>
171149
</InlineAlert>
172150

151+
### Breakpoints
152+
153+
The style macro has several predefined [breakpoints](./styling/reference.html#conditions), but you can use arbitrary CSS media or container queries as [conditional values](./styling/advanced.html#conditional-styles) in your style macro as well.
154+
173155
## CSS optimization
174156

175157
The `style` macro relies on CSS bundling and minification for optimal output. Follow these best practices:
@@ -238,7 +220,7 @@ in a non-atomic format, making it easier to scan.
238220
the `style` macros for quick prototyping.
239221

240222
- If you are using Cursor, we offer a set of [Cursor rules](https://github.com/adobe/react-spectrum/blob/main/rules/style-macro.mdc) to use when developing with style macros. Additionally,
241-
we have MCP servers for [React Aria](#TODO) and [React Spectrum](https://www.npmjs.com/package/@react-spectrum/mcp) respectively that interface with the docs.
223+
we have MCP servers for [React Aria](../react-aria/mcp.html) and [React Spectrum](./mcp.html) respectively that interface with the docs.
242224

243225
## FAQ
244226

packages/dev/s2-docs/pages/s2/styling/Advanced.mdx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ export default Layout;
33

44
export const omitFromNav = true;
55
export const tags = ['style', 'macro', 'spectrum', 'custom', 'advanced'];
6-
export const description = 'Style macro advanced usage guide';
6+
export const description = 'A guide to advanced styling use cases for React Spectrum';
77

8-
# Advanced style macro usage
8+
# Advanced styling guide
99

10-
A guide to advanced use cases with the `style` macro.
10+
A guide to advanced styling use cases for React Spectrum.
1111

1212
## Conditional styles
1313

@@ -18,7 +18,8 @@ Define conditional values as objects to handle media queries, UI states (hover/p
1818
className={style({
1919
padding: {
2020
default: 8,
21-
lg: 32
21+
lg: 32,
22+
'@media (min-width: 2560px)': 64,
2223
}
2324
})}
2425
/>
@@ -215,3 +216,26 @@ function MyComponent({isQuiet, styles}: {isQuiet?: boolean, styles?: StyleString
215216
```
216217

217218
The `iconStyle` macro should be used when styling Icons, see the [docs](../icons.html#iconstyle) for more information.
219+
220+
## UNSAFE Style Overrides
221+
222+
We highly discourage overriding the styles of React Spectrum components because it may break at any time when we change our implementation, making it difficult for you to update in the future. Consider using [React Aria Components](https://react-spectrum.adobe.com/react-aria/) with our `style` macro to build a custom component with Spectrum styles instead.
223+
224+
With that being said, the `UNSAFE_className` and `UNSAFE_style` props are supported on Spectrum 2 components as last-resort escape hatches.
225+
226+
```tsx
227+
/* YourComponent.tsx */
228+
import {Button} from '@react-spectrum/s2';
229+
import './YourComponent.css';
230+
231+
function YourComponent() {
232+
return <Button UNSAFE_className="your-unsafe-class">Button</Button>;
233+
}
234+
```
235+
236+
```css
237+
/* YourComponent.css */
238+
.your-unsafe-class {
239+
background: red;
240+
}
241+
```

0 commit comments

Comments
 (0)