Skip to content

Commit 305737d

Browse files
docs: improve typography section, syntax
1 parent ca49b6f commit 305737d

File tree

1 file changed

+61
-48
lines changed

1 file changed

+61
-48
lines changed

1st-gen/tools/styles/README.md

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,39 @@ See the `@spectrum-web-components/theme` [documentation](../theme) for more info
2626
yarn add @spectrum-web-components/styles
2727
```
2828

29-
## System variants
29+
### System variants
3030

3131
This package provides styles for three Adobe design system variants (referred to as "systems"). Each system has different available color options:
3232

33-
- **Spectrum Legacy** (system: `spectrum`) - The original Spectrum design system with four color options: `dark`, `light`, and deprecated `darkest` and `lightest`
33+
- **Spectrum** (system: `spectrum`) - The original Spectrum design system with four color options: `dark`, `light`, and deprecated `darkest` and `lightest`
3434
- **Express** (system: `express`) - The Adobe Express design system with two color options: `dark` and `light`
3535
- **Spectrum 2** (system: `spectrum-two`) - The next generation Spectrum design system with two color options: `dark` and `light`
3636

37-
## Combined theme packages (Spectrum Legacy)
37+
### Combined theme packages (Spectrum)
3838

39-
If you're not using `<sp-theme>`, the styles package provides convenience bundles for Spectrum Legacy that combine everything you need in a single import. Each `all-*` file combines core global styles, typography, a color option, and a scale specification. Express and Spectrum 2 do not have equivalent combined packages; use manual theme composition instead (see below).
39+
If you're not using `<sp-theme>`, the styles package provides convenient bundles for Spectrum that combine everything you need in a single import. Each `all-*` file combines core global styles, typography, a color option, and a scale specification. Express and Spectrum 2 do not have equivalent combined packages; use manual theme composition instead (see below).
4040

4141
> **Note:** The `darkest` and `lightest` colors are deprecated and will be removed in a future release. Use `dark` or `light` instead.
4242
43-
```ts
43+
```css
4444
@import '@spectrum-web-components/styles/all-medium-dark.css';
4545
```
4646

4747
This file brings together the global variables and font settings with the "Dark" color set and "Medium" scale system specification.
4848

49-
```ts
49+
```css
5050
@import '@spectrum-web-components/styles/all-medium-light.css';
5151
```
5252

5353
This file brings together the global variables and font settings with the "Light" color set and "Medium" scale system specification.
5454

5555
Other available combinations: `all-large-dark.css`, `all-large-light.css`, and the deprecated `all-medium-darkest.css`, `all-medium-lightest.css`, `all-large-darkest.css`, `all-large-lightest.css`.
5656

57-
## Manual theme composition (Express and Spectrum 2)
57+
### Manual theme composition (Express and Spectrum 2)
5858

59-
If you're not using `<sp-theme>`, you can manually compose a complete theme for Express or Spectrum 2 (equivalent to the `all-*` convenience packages for Spectrum Legacy) by importing four files: core global styles, typography, a color option, and a scale.
59+
If you're not using `<sp-theme>`, you can manually compose a complete theme for Express or Spectrum 2 (equivalent to the `all-*` convenience packages for Spectrum) by importing four files: core global styles, typography, a color option, and a scale.
6060

61-
**Express example (large, dark):**
61+
#### Express example (large, dark)
6262

6363
```css
6464
@import '@spectrum-web-components/styles/express/core-global.css';
@@ -67,7 +67,7 @@ If you're not using `<sp-theme>`, you can manually compose a complete theme for
6767
@import '@spectrum-web-components/styles/express/scale-large.css';
6868
```
6969

70-
**Spectrum 2 example (medium, light):**
70+
#### Spectrum 2 example (medium, light)
7171

7272
```css
7373
@import '@spectrum-web-components/styles/spectrum-two/core-global.css';
@@ -78,16 +78,16 @@ If you're not using `<sp-theme>`, you can manually compose a complete theme for
7878

7979
> **Note:** For most use cases, we recommend using `<sp-theme>` instead of manually managing these imports. The theme element handles composition and switching automatically.
8080
81-
## Individual theme and scale files
81+
### Individual theme and scale files
8282

8383
For more control over bundle size or to manually compose themes, you can import color and scale files individually. These provide only the CSS custom properties specific to color or scale, without the combined overhead of the `all-*` packages.
8484

85-
### Color
85+
#### Color
8686

8787
Import a single color option to set color values:
8888

8989
```css
90-
/* Spectrum Legacy */
90+
/* Spectrum */
9191
@import '@spectrum-web-components/styles/theme-light.css';
9292

9393
/* Express */
@@ -97,7 +97,7 @@ Import a single color option to set color values:
9797
@import '@spectrum-web-components/styles/spectrum-two/theme-light.css';
9898
```
9999

100-
**Available color options:**
100+
##### Available color options
101101

102102
<sp-table>
103103
<sp-table-head>
@@ -106,7 +106,7 @@ Import a single color option to set color values:
106106
</sp-table-head>
107107
<sp-table-body>
108108
<sp-table-row>
109-
<sp-table-cell><strong>Spectrum Legacy</strong></sp-table-cell>
109+
<sp-table-cell><strong>Spectrum</strong></sp-table-cell>
110110
<sp-table-cell><code>theme-dark.css</code>, <code>theme-light.css</code>, <code>theme-darkest.css</code> (deprecated), <code>theme-lightest.css</code> (deprecated)</sp-table-cell>
111111
</sp-table-row>
112112
<sp-table-row>
@@ -122,12 +122,12 @@ Import a single color option to set color values:
122122

123123
> **Note:** All color theme files automatically set the CSS `color-scheme` property (`light` or `dark`) for accessibility. This helps browsers render native form controls appropriately, adjusts scrollbar colors to match the theme, and improves compatibility with system UI elements.
124124
125-
### Scale
125+
#### Scale
126126

127127
Import a single scale to set sizing values:
128128

129129
```css
130-
/* Spectrum Legacy */
130+
/* Spectrum */
131131
@import '@spectrum-web-components/styles/scale-medium.css';
132132

133133
/* Express */
@@ -137,7 +137,7 @@ Import a single scale to set sizing values:
137137
@import '@spectrum-web-components/styles/spectrum-two/scale-large.css';
138138
```
139139

140-
**Available scales:**
140+
##### Available scales
141141

142142
<sp-table>
143143
<sp-table-head>
@@ -146,7 +146,7 @@ Import a single scale to set sizing values:
146146
</sp-table-head>
147147
<sp-table-body>
148148
<sp-table-row>
149-
<sp-table-cell><strong>Spectrum Legacy</strong></sp-table-cell>
149+
<sp-table-cell><strong>Spectrum</strong></sp-table-cell>
150150
<sp-table-cell><code>scale-medium.css</code>, <code>scale-large.css</code></sp-table-cell>
151151
</sp-table-row>
152152
<sp-table-row>
@@ -160,15 +160,11 @@ Import a single scale to set sizing values:
160160
</sp-table-body>
161161
</sp-table>
162162

163-
## Typography
164-
165-
```ts
166-
@import '@spectrum-web-components/styles/typography.css';
167-
```
163+
### Typography
168164

169-
This file provides the complete [Spectrum Typography system](https://opensource.adobe.com/spectrum-css/?path=/docs/components-typography--docs). The typography system is shared across all design systems (Spectrum Legacy, Express, and Spectrum 2).
165+
The [Spectrum Typography system](https://opensource.adobe.com/spectrum-css/?path=/docs/components-typography--docs) provides a complete set of text styles. The typography system is shared across all design systems (Spectrum, Express, and Spectrum 2).
170166

171-
**What's included:**
167+
#### What's included
172168

173169
- **Heading** styles (`.spectrum-Heading`) - Multiple sizes from XXS to XXXL with weight variants (light, regular, heavy) and serif options
174170
- **Body** styles (`.spectrum-Body`) - Multiple sizes from XS to XXXL with serif options for body copy and longer text
@@ -178,63 +174,80 @@ This file provides the complete [Spectrum Typography system](https://opensource.
178174
- **Emphasis and strong** - Proper italic and bold styling for `<em>` and `<strong>` elements within each typography class
179175
- **High contrast mode support** - Ensures text remains readable when Windows High Contrast Mode is enabled
180176

181-
### TypeScript/JavaScript exports for Lit components
177+
#### CSS imports
178+
179+
For stylesheet use, import the complete typography system:
180+
181+
```css
182+
@import '@spectrum-web-components/styles/typography.css';
183+
```
184+
185+
#### TypeScript/JavaScript exports for Lit components
186+
187+
For use in Lit-based components, you can import typography styles as JavaScript modules. Import the complete system or individual components depending on your needs:
182188

183-
For use in Lit-based components, you can import typography styles as JavaScript modules:
189+
##### Import everything
184190

185-
```ts
191+
```js
186192
import typographyStyles from '@spectrum-web-components/styles/typography.js';
187-
import bodyStyles from '@spectrum-web-components/styles/body.js';
188-
import headingStyles from '@spectrum-web-components/styles/heading.js';
189-
import detailStyles from '@spectrum-web-components/styles/detail.js';
190-
import codeStyles from '@spectrum-web-components/styles/code.js';
191193

192-
// Use in your component's static styles
193194
static styles = [typographyStyles];
194195
```
195196

196-
- **`typography.js`** - Complete typography system with all classes
197-
- **`body.js`** - Body text styles only (base + lang + body classes)
198-
- **`heading.js`** - Heading styles only (base + lang + heading classes)
199-
- **`detail.js`** - Detail/label styles only (base + lang + detail classes)
200-
- **`code.js`** - Code styles only (base + lang + code classes)
197+
##### Import only what you need
198+
199+
For smaller bundle sizes, import individual components:
200+
201+
```js
202+
import headingStyles from '@spectrum-web-components/styles/heading.js';
203+
204+
static styles = [headingStyles];
205+
```
201206

202-
Import individual exports when you only need specific typography components to reduce bundle size.
207+
##### Available JavaScript exports
203208

204-
## Design tokens
209+
- **`typography.js`** - Complete typography system with all styles (heading, body, detail, code)
210+
- **`body.js`** - Body text styles only (includes base + lang + body)
211+
- **`heading.js`** - Heading styles only (includes base + lang + heading)
212+
- **`detail.js`** - Detail/label styles only (includes base + lang + detail)
213+
- **`code.js`** - Code styles only (includes base + lang + code)
214+
215+
Each individual export (`body.js`, `heading.js`, etc.) includes the necessary base and language support styles, so you don't need to import them separately. Import `typography.js` for the complete system, or import individual exports to reduce bundle size.
216+
217+
### Design tokens
205218

206219
For advanced use cases where you need direct access to design token CSS custom properties, this package exposes token files:
207220

208-
### Spectrum Legacy tokens
221+
#### Spectrum tokens
209222

210-
```ts
223+
```css
211224
@import '@spectrum-web-components/styles/tokens/global-vars.css';
212225
@import '@spectrum-web-components/styles/tokens/light-vars.css';
213226
@import '@spectrum-web-components/styles/tokens/dark-vars.css';
214227
@import '@spectrum-web-components/styles/tokens/medium-vars.css';
215228
@import '@spectrum-web-components/styles/tokens/large-vars.css';
216229
```
217230

218-
### Express tokens
231+
#### Express tokens
219232

220-
```ts
233+
```css
221234
@import '@spectrum-web-components/styles/tokens/express/global-vars.css';
222235
@import '@spectrum-web-components/styles/tokens/express/light-vars.css';
223236
@import '@spectrum-web-components/styles/tokens/express/dark-vars.css';
224237
@import '@spectrum-web-components/styles/tokens/express/medium-vars.css';
225238
@import '@spectrum-web-components/styles/tokens/express/large-vars.css';
226239
```
227240

228-
### Spectrum 2 tokens
241+
#### Spectrum 2 tokens
229242

230-
```ts
243+
```css
231244
@import '@spectrum-web-components/styles/tokens-v2/global-vars.css';
232245
@import '@spectrum-web-components/styles/tokens-v2/light-vars.css';
233246
@import '@spectrum-web-components/styles/tokens-v2/dark-vars.css';
234247
@import '@spectrum-web-components/styles/tokens-v2/medium-vars.css';
235248
@import '@spectrum-web-components/styles/tokens-v2/large-vars.css';
236249
```
237250

238-
## Migrating to Spectrum 2
251+
### Migrating to Spectrum 2
239252

240253
If you're migrating to Spectrum 2, see the [Spectrum 2 migration guide](../../migrating-to-spectrum2/) for detailed instructions.

0 commit comments

Comments
 (0)