Skip to content

Commit 854fec2

Browse files
committed
Suggested edits
1 parent edbe4f5 commit 854fec2

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
@@ -437,10 +437,6 @@ interface HostContext {
437437
}
438438
```
439439

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

446442
```json
@@ -457,7 +453,8 @@ Example:
457453
"styles": {
458454
"--color-background-primary": "light-dark(#ffffff, #171717)",
459455
"--color-text-primary": "light-dark(#171717, #fafafa)",
460-
"--font-family-sans": "system-ui, sans-serif"
456+
"--font-family-sans": "system-ui, sans-serif",
457+
...
461458
},
462459
"displayMode": "inline",
463460
"viewport": { "width": 400, "height": 300 }
@@ -468,9 +465,9 @@ Example:
468465

469466
### Theming
470467

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

473-
#### Standardized Variables
470+
#### Current Standardized Variables
474471

475472
| Category | Variables |
476473
|----------|-----------|
@@ -489,26 +486,27 @@ Hosts pass CSS custom properties via `HostContext.styles` for visual cohesion wi
489486

490487
#### Host Behavior
491488

492-
- Hosts MAY provide any subset of standardized variables
493-
- Hosts MAY use CSS `light-dark()` function for theme-aware values
494-
- `theme` indicates the active mode; `styles` provides the concrete CSS values
489+
- 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
490+
- Hosts can use the CSS `light-dark()` function for theme-aware values
495491

496492
#### App Behavior
497493

498-
- Apps SHOULD use fallback values for CSS variables: `var(--color-text-primary, #171717)`
499-
- This ensures graceful degradation when hosts omit `styles` or specific variables
500-
- When the host uses `light-dark()` values, apps MUST set `color-scheme` on their document:
501-
```css
502-
:root { color-scheme: light dark; }
503-
```
494+
- 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:
495+
```
496+
:root {
497+
--colorTextPrimary: #171717;
498+
}
499+
```
500+
- 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
501+
- 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
504502

505-
Example CSS:
503+
Example usage of standardized CSS variables:
506504

507505
```css
508506
.container {
509-
background: var(--color-background-primary, #ffffff);
510-
color: var(--color-text-primary, #171717);
511-
font: var(--font-style-body, 400 16px/1.4 system-ui);
507+
background: var(--color-background-primary);
508+
color: var(--color-text-primary);
509+
font: var(--font-style-body);
512510
}
513511
```
514512

0 commit comments

Comments
 (0)