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>Spectrum 2 offers a subset of the icons currently available in React Spectrum v3. These icons can be imported from <Code>@react-spectrum/s2/icons</Code>.</P>
<P><strong>Introducing <Linkhref="https://s2.spectrum.adobe.com"target="_blank">Spectrum 2</Link></strong> – a new update to Adobe's design system, now in pre-release! Designed to support our growing suite of products, Spectrum 2 aims to work seamlessly across experiences by balancing personality and function.</P>
33
+
<P><Strong>Introducing <Linkhref="https://s2.spectrum.adobe.com"target="_blank">Spectrum 2</Link></Strong> – a new update to Adobe's design system, now in pre-release! Designed to support our growing suite of products, Spectrum 2 aims to work seamlessly across experiences by balancing personality and function.</P>
34
34
<P>The React Spectrum team has been hard at work to bring the Spectrum 2 design to our components. Spectrum 2 in React Spectrum is built on <Linkhref="https://react-spectrum.adobe.com/react-aria/"target="_blank">React Aria Components</Link> and a new styling foundation powered by <Linkhref="https://github.com/adobe/spectrum-tokens"target="_blank">Spectrum Tokens</Link>. This gives you access to Spectrum design fundamentals such as colors, spacing, sizing, and typography in your own applications and custom components. Spectrum 2 also brings new features such as t-shirt sizing, improved form layout, dynamic new press interactions, and more.</P>
35
35
<P>Check out the new Button design, with fresh new colors and icons, a fun new press scaling interaction, and support for t-shirt sizes.</P>
<P><strong>Note</strong>: If you’re embedding Spectrum 2 as a section of a larger page rather than taking over the whole window, follow the <Linkhref="#embedded-sections"target="_self">directions below</Link> instead of using <Code>page.css</Code>.</P>
159
+
<P><Strong>Note</Strong>: If you’re embedding Spectrum 2 as a section of a larger page rather than taking over the whole window, follow the <Linkhref="#embedded-sections"target="_self">directions below</Link> instead of using <Code>page.css</Code>.</P>
160
160
<H3>Overriding the color scheme</H3>
161
161
<P>By default, the page follows the user’s operating system color scheme setting, supporting both light and dark mode. The page background is set to the <Code>base</Code> Spectrum background layer by default. This can be configured by setting the <Code>data-color-scheme</Code> and <Code>data-background</Code> attributes on the <Code>{'<html>'}</Code> element. For example, to force the application to only render in light mode, set <Code>data-color-scheme="light"</Code>.</P>
<P><strong>Atomic CSS</strong> scales as your application grows because it outputs a separate rule for each CSS property you write, ensuring there is no duplication across your whole app. The above example generates two CSS rules:</P>
25
+
<P><Strong>Atomic CSS</Strong> scales as your application grows because it outputs a separate rule for each CSS property you write, ensuring there is no duplication across your whole app. The above example generates two CSS rules:</P>
<P>These rules are reused across your app wherever the same values are used, which keeps your bundle size small even as you add features. In addition, you only pay for the values you use – there’s no unnecessary CSS custom properties for colors and other tokens that aren’t used.</P>
29
-
<P>The <Code>style</Code> macro <strong>colocates</strong> your styles with your component code, rather than in separate CSS files. Colocation enables you to:</P>
29
+
<P>The <Code>style</Code> macro <Strong>colocates</Strong> your styles with your component code, rather than in separate CSS files. Colocation enables you to:</P>
30
30
<ulclassName="sb-unstyled">
31
-
<liclassName={style({lineHeight: 'body',color: 'body',marginTop: 0,marginBottom: 8})}><strong>Develop more efficiently</strong> – No need to switch between multiple files when working on a component, or spend time writing CSS selectors.</li>
32
-
<liclassName={style({lineHeight: 'body',color: 'body',marginY: 0})}><strong>Refactor with confidence</strong> – Changing the styles in a component is guaranteed to never unintentionally affect any other parts of your application. When you delete a component, the corresponding styles are also removed, reducing technical debt.</li>
31
+
<liclassName={style({font: 'body-lg',marginTop: 0,marginBottom: 8})}><Strong>Develop more efficiently</Strong> – No need to switch between multiple files when working on a component, or spend time writing CSS selectors.</li>
32
+
<liclassName={style({font: 'body-lg',marginY: 0})}><Strong>Refactor with confidence</Strong> – Changing the styles in a component is guaranteed to never unintentionally affect any other parts of your application. When you delete a component, the corresponding styles are also removed, reducing technical debt.</li>
33
33
</ul>
34
34
<H2>Values</H2>
35
35
<P>The <Code>style</Code> macro supports a constrained set of values for each CSS property, which conform to the Spectrum design system. For example, the <Code>backgroundColor</Code> property supports Spectrum colors, and does not allow arbitrary hex or rgb values by default. This helps make it easier to build consistent UIs that are maintainable over time.</P>
@@ -60,6 +60,7 @@ export function StyleMacro() {
60
60
}
61
61
}
62
62
});
63
+
63
64
function MyComponent({variant}) {
64
65
return <div className={styles({variant})} />
65
66
}`)}</Pre>
@@ -70,9 +71,11 @@ function MyComponent({variant}) {
<P>Runtime conditions also work well with the <Linkhref="https://react-spectrum.adobe.com/react-aria/styling.html#render-props"target="_blank">render props</Link> in React Aria Components. If you define your styles inline, you’ll even get autocomplete for all of the available conditions.</P>
75
77
<Pre>{highlight(`import {Checkbox} from 'react-aria-components';
78
+
76
79
<Checkbox
77
80
className={style({
78
81
backgroundColor: {
@@ -97,6 +100,7 @@ function MyComponent({variant}) {
<P>The above example has three runtime conditions (<Code>isSelected</Code>, <Code>isEmphasized</Code>, and <Code>isDisabled</Code>), and uses the <Code>forcedColors</Code> condition to apply styles for <Linkhref="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors"target="_blank">Windows High Contrast Mode</Link> (WHCM). The order of precedence follows the order the conditions are defined in the object, with the <Code>isSelected</Code> + <Code>isDisabled</Code> + <Code>forcedColors</Code> state having the highest priority.</P>
102
106
<H2>Reusing styles</H2>
@@ -106,6 +110,7 @@ function MyComponent({variant}) {
106
110
alignItems: 'center',
107
111
columnGap: 8
108
112
};
113
+
109
114
const styles = style({
110
115
...horizontalStack,
111
116
columnGap: 4
@@ -122,6 +127,7 @@ export function horizontalStack(gap: number) {
122
127
<P>Then, import your macro and use it in a component.</P>
123
128
<Pre>{highlight(`// component.tsx
124
129
import {horizontalStack} from './style-utils' with {type: 'macro'};
0 commit comments