Skip to content

Commit aaedd85

Browse files
committed
Suggested edits
1 parent bcc0543 commit aaedd85

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

specification/draft/apps.mdx

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,6 @@ interface HostContext {
440440
}
441441
```
442442

443-
All fields are optional. Hosts SHOULD provide relevant context. Guest UIs SHOULD handle missing fields gracefully.
444-
445-
For `styles`, apps SHOULD provide CSS fallback values (e.g., `var(--color-text-primary, #171717)`) to handle hosts that don't supply styles.
446-
447443
Example:
448444

449445
```json
@@ -460,7 +456,8 @@ Example:
460456
"styles": {
461457
"--color-background-primary": "light-dark(#ffffff, #171717)",
462458
"--color-text-primary": "light-dark(#171717, #fafafa)",
463-
"--font-family-sans": "system-ui, sans-serif"
459+
"--font-family-sans": "system-ui, sans-serif",
460+
...
464461
},
465462
"displayMode": "inline",
466463
"viewport": { "width": 400, "height": 300 }
@@ -471,9 +468,9 @@ Example:
471468

472469
### Theming
473470

474-
Hosts pass CSS custom properties via `HostContext.styles` for visual cohesion with the host environment.
471+
Hosts can optionally pass CSS custom properties via `HostContext.styles` for visual cohesion with the host environment.
475472

476-
#### Standardized Variables
473+
#### Current Standardized Variables
477474

478475
| Category | Variables |
479476
|----------|-----------|
@@ -492,26 +489,27 @@ Hosts pass CSS custom properties via `HostContext.styles` for visual cohesion wi
492489

493490
#### Host Behavior
494491

495-
- Hosts MAY provide any subset of standardized variables
496-
- Hosts MAY use CSS `light-dark()` function for theme-aware values
497-
- `theme` indicates the active mode; `styles` provides the concrete CSS values
492+
- Hosts can provide any subset of standardized variables, or not pass `styles` at all. However, passing all of the standardized properties is recommended for cohesiveness
493+
- Hosts can use the CSS `light-dark()` function for theme-aware values
498494

499495
#### App Behavior
500496

501-
- Apps SHOULD use fallback values for CSS variables: `var(--color-text-primary, #171717)`
502-
- This ensures graceful degradation when hosts omit `styles` or specific variables
503-
- When the host uses `light-dark()` values, apps MUST set `color-scheme` on their document:
504-
```css
505-
:root { color-scheme: light dark; }
506-
```
497+
- Apps should set default fallback values for CSS variables, to account for hosts who don't pass some or all style variables. This ensures graceful degradation when hosts omit `styles` or specific variables:
498+
```
499+
:root {
500+
--colorTextPrimary: #171717;
501+
}
502+
```
503+
- Apps can use the `applyHostStyles` utility (or `useHostStyles` if they prefer a React hook) to easily populate the host-provided CSS variables into their style sheet
504+
- Apps can use the `applyDocumentTheme` utility (or `useDocumentTheme` if they prefer a React hook) to easily respond to Host Context `theme` changes in a way that is compatible with the host's light/dark color variables
507505

508-
Example CSS:
506+
Example usage of standardized CSS variables:
509507

510508
```css
511509
.container {
512-
background: var(--color-background-primary, #ffffff);
513-
color: var(--color-text-primary, #171717);
514-
font: var(--font-style-body, 400 16px/1.4 system-ui);
510+
background: var(--color-background-primary);
511+
color: var(--color-text-primary);
512+
font: var(--font-style-body);
515513
}
516514
```
517515

0 commit comments

Comments
 (0)