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
Copy file name to clipboardExpand all lines: docs/guides/new-theme-overrides.md
+224-8Lines changed: 224 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,8 +97,8 @@ type: example
97
97
infoIconBackground:'purple'
98
98
},
99
99
Pill: {
100
-
primaryBackground:'purple',
101
-
primaryBorderColor:'purple'
100
+
baseTextColor:'purple',
101
+
baseBorderColor:'purple'
102
102
}
103
103
}
104
104
}}
@@ -274,7 +274,7 @@ type: example
274
274
</InstUISettingsProvider>
275
275
```
276
276
277
-
### 8. Per-component`themeOverride` prop
277
+
### 8. Component's`themeOverride` prop
278
278
279
279
Individual component instances accept a `themeOverride` prop for one-off styling. This overrides the component's own tokens and takes highest priority.
280
280
@@ -284,7 +284,7 @@ Individual component instances accept a `themeOverride` prop for one-off styling
284
284
---
285
285
type: example
286
286
---
287
-
<InstUISettingsProvider theme={canvas}>
287
+
<div>
288
288
<Alert variant="info" margin="small">
289
289
Default info Alert.
290
290
</Alert>
@@ -298,7 +298,7 @@ type: example
298
298
>
299
299
This specific Alert has crimson info styling.
300
300
</Alert>
301
-
</InstUISettingsProvider>
301
+
</div>
302
302
```
303
303
304
304
#### Function form
@@ -390,10 +390,226 @@ type: example
390
390
</InstUISettingsProvider>
391
391
```
392
392
393
+
### 11. Overriding shared tokens
394
+
395
+
Shared tokens are cross-component design tokens for common UI patterns like focus outlines, spacing, border radii, and elevation shadows. They sit alongside semantics and are passed to all component style functions. Overriding shared tokens affects every component that uses them.
396
+
397
+
#### Focus outline
398
+
399
+
The `focusOutline` shared tokens control the focus ring appearance across all focusable components.
400
+
401
+
```js
402
+
---
403
+
type: example
404
+
---
405
+
<InstUISettingsProvider theme={light}>
406
+
<TextInput renderLabel="Default focus ring" placeholder="Click to focus me"/>
407
+
408
+
<View as="div" margin="small 0 0 0">
409
+
<InstUISettingsProvider
410
+
themeOverride={{
411
+
sharedTokens: {
412
+
focusOutline: {
413
+
width:'0.25rem',
414
+
infoColor:'deeppink'
415
+
}
416
+
}
417
+
}}
418
+
>
419
+
<TextInput renderLabel="Custom focus ring" placeholder="Click to focus me"/>
420
+
</InstUISettingsProvider>
421
+
</View>
422
+
</InstUISettingsProvider>
423
+
```
424
+
425
+
#### Box shadow (elevation)
426
+
427
+
The `boxShadow` shared tokens control elevation shadows. Components like `Alert` use these to render drop shadows.
Shared tokens can be combined with primitives, semantics, and component overrides in a single `themeOverride`.
460
+
461
+
```js
462
+
---
463
+
type: example
464
+
---
465
+
<InstUISettingsProvider theme={light}>
466
+
<InstUISettingsProvider
467
+
themeOverride={{
468
+
sharedTokens: {
469
+
focusOutline: {
470
+
width:'0.25rem',
471
+
infoColor:'darkorange'
472
+
}
473
+
},
474
+
components: {
475
+
Alert: {
476
+
infoBorderColor:'darkorange',
477
+
infoIconBackground:'darkorange'
478
+
}
479
+
}
480
+
}}
481
+
>
482
+
<Alert variant="info" margin="small">
483
+
Alert with orange info styling.
484
+
</Alert>
485
+
<View as="div" margin="small 0 0 0">
486
+
<TextInput renderLabel="Matching orange focus ring" placeholder="Click to focus me"/>
487
+
</View>
488
+
</InstUISettingsProvider>
489
+
</InstUISettingsProvider>
490
+
```
491
+
492
+
### 12. Overrides on internal child components
493
+
494
+
Some components render other components internally. For example, `Button` renders `BaseButton` internally. Provider-level `components.BaseButton` overrides affect all BaseButton instances, including those rendered inside `Button`.
When a provider sets `components.BaseButton` overrides, a specific `Button` instance can override those via its own `themeOverride` prop. The per-component prop has the highest priority.
524
+
525
+
```js
526
+
---
527
+
type: example
528
+
---
529
+
<InstUISettingsProvider theme={canvas}>
530
+
<InstUISettingsProvider
531
+
themeOverride={{
532
+
components: {
533
+
BaseButton: {
534
+
primaryBackground:'rebeccapurple',
535
+
primaryBorderColor:'rebeccapurple'
536
+
}
537
+
}
538
+
}}
539
+
>
540
+
<BaseButton color="primary" margin="small">
541
+
BaseButton -purple (from provider)
542
+
</BaseButton>
543
+
<Button color="primary" margin="small">
544
+
Button - also purple (inherits BaseButton override)
### 14. Overrides on functional (`useStyle`) components
561
+
562
+
All override patterns work identically on functional components that use the `useStyle` hook. Here, Avatar tokens are overridden the same way as class-based components using `withStyle`.
563
+
564
+
```js
565
+
---
566
+
type: example
567
+
---
568
+
<InstUISettingsProvider theme={light}>
569
+
<Avatar name="Default" color="accent1" margin="0 small 0 0"/>
570
+
571
+
<InstUISettingsProvider
572
+
themeOverride={{
573
+
components: {
574
+
Avatar: {
575
+
backgroundColor:'navy',
576
+
blueTextColor:'lime'
577
+
}
578
+
}
579
+
}}
580
+
>
581
+
<Avatar name="Overridden" color="accent1" margin="0 small 0 0"/>
582
+
<Avatar name="Unaffected" color="accent2"/>
583
+
</InstUISettingsProvider>
584
+
</InstUISettingsProvider>
585
+
```
586
+
587
+
### 15. Function form `themeOverride` on functional components
588
+
589
+
The function form also works on `useStyle` components. The function receives the component's calculated theme as the first argument, letting you derive overrides from existing token values.
590
+
591
+
```js
592
+
---
593
+
type: example
594
+
---
595
+
<InstUISettingsProvider theme={light}>
596
+
<Avatar name="Default Blue" color="accent1" margin="0 small 0 0"/>
0 commit comments