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>To use custom icons, you first need to convert your SVGs into compatible icon components. This depends on your bundler.</P>
34
+
<H3>Parcel</H3>
35
+
<P>If you are using Parcel, the <Code>@react-spectrum/parcel-transformer-s2-icon</Code> plugin can be used to convert SVGs to icon components. First install it into your project as a dev dependency:</P>
<P>This outputs a folder of TSX files with names corresponding to the input SVG files. You may rename them as you wish. To use them in your application, import them like normal components.</P>
50
+
<Pre>{highlight(`import Icon from './path/to/destination/Icon';`)}</Pre>
@@ -74,6 +74,25 @@ export function Illustrations() {
74
74
);
75
75
})}
76
76
</div>
77
+
<H2>Custom illustrations</H2>
78
+
<P>To use custom illustrations, you first need to convert your SVGs into compatible illustration components. This depends on your bundler.</P>
79
+
<H3>Parcel</H3>
80
+
<P>If you are using Parcel, the <Code>@react-spectrum/parcel-transformer-s2-icon</Code> plugin can be used to convert SVGs to illustration components. First install it into your project as a dev dependency:</P>
<P>Now you can import illustration SVGs using the <Code>illustration:</Code><Linkhref="https://parceljs.org/features/plugins/#named-pipelines">pipeline</Link>:</P>
90
+
<Pre>{highlight(`import Illustration from 'illustration:./path/to/Illustration.svg';`)}</Pre>
91
+
<H3>Other bundlers</H3>
92
+
<P>The <Code>@react-spectrum/s2-icon-builder</Code> CLI tool can be used to pre-process a folder of SVG illustrations into TSX files.</P>
<P>This outputs a folder of TSX files with names corresponding to the input SVG files. You may rename them as you wish. To use them in your application, import them like normal components.</P>
95
+
<Pre>{highlight(`import Illustration from './path/to/destination/Illustration';`)}</Pre>
<P>By default, React Spectrum uses the browser/operating system language setting for localized strings, date and number formatting, and to determine the layout direction (left-to-right or right-to-left). This can be overridden by rendering a <Code>{'<Provider>'}</Code> component at the root of your app, and setting the <Code>locale</Code> prop.</P>
167
167
<Pre>{highlight(`import {Provider} from '@react-spectrum/s2';
168
+
168
169
<Provider locale="en-US">
169
170
{/* your app */}
170
171
</Provider>`)}</Pre>
171
172
<H3>Embedded sections</H3>
172
173
<P>If you’re building an embedded section of a larger page using Spectrum 2, use the <Code>{'<Provider>'}</Code> component to set the background instead of importing <Code>page.css</Code>. The <Code>background</Code> prop should be set to the Spectrum background layer appropriate for your app, and the <Code>colorScheme</Code> can be overridden as well.</P>
173
174
<Pre>{highlight(`import {Provider} from '@react-spectrum/s2';
175
+
174
176
<Provider background="base">
175
177
{/* your app */}
176
178
</Provider>`)}</Pre>
@@ -186,7 +188,7 @@ import {ActionButton} from '@react-spectrum/s2';
186
188
<P>The <Code>styles</Code> prop accepts a limited set of CSS properties, including layout, spacing, sizing, and positioning. Other styles such as colors and internal padding cannot be customized within Spectrum components.</P>
<Content>See the <Linkhref="/?path=/docs/style-macro--docs"variant="secondary"target="_top">full docs</Link> to learn about using the style macro to build custom components.</Content>
191
+
<Content>See the <Linkhref="?path=/docs/style-macro--docs"variant="secondary"target="_top">full docs</Link> to learn about using the style macro to build custom components.</Content>
190
192
</InlineAlert>
191
193
<H3>Supported CSS properties on Spectrum components</H3>
@@ -225,7 +227,7 @@ import {ActionButton} from '@react-spectrum/s2';
225
227
<li><Code>insetEnd</Code></li>
226
228
</ul>
227
229
<H3>UNSAFE Style Overrides</H3>
228
-
<P>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 <Linkhref="https://react-spectrum.adobe.com/react-aria/"target="_blank">React Aria Components</Link> with our <Linkhref="/?path=/docs/style-macro--docs"target="_top">style macro</Link> to build a custom component with Spectrum styles instead.</P>
230
+
<P>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 <Linkhref="https://react-spectrum.adobe.com/react-aria/"target="_blank">React Aria Components</Link> with our <Linkhref="?path=/docs/style-macro--docs"target="_top">style macro</Link> to build a custom component with Spectrum styles instead.</P>
229
231
<P>That said, just like in React Spectrum v3, the <Code>UNSAFE_className</Code> and <Code>UNSAFE_style</Code> props are supported on Spectrum 2 components as last-resort escape hatches. However, unlike in v3, UNSAFE_classNames must be placed in a special <Code>UNSAFE_overrides</Code><Linkhref="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Cascade_layers"target="_blank">CSS cascade layer</Link>. This guarentees that your overrides will always win over other styles on the page, no matter the order or specificity of the selector.</P>
0 commit comments