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: references/react-sdk.mdx
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,7 @@ type DashboardProps = {
101
101
token:string|Promise<string>; // JWT (can be async)
102
102
103
103
// Optional
104
+
theme?:'light'|'dark'; // Force light or dark color scheme
104
105
styles?: {
105
106
backgroundColor?:string; // Background color or 'transparent'
106
107
fontFamily?:string; // Font family for all text
@@ -200,6 +201,7 @@ type ChartProps = {
200
201
token:string|Promise<string>; // JWT with type: 'chart'
201
202
202
203
// Optional
204
+
theme?:'light'|'dark'; // Force light or dark color scheme
203
205
styles?: {
204
206
backgroundColor?:string; // Background color or 'transparent'
205
207
fontFamily?:string; // Font family for all text
@@ -278,6 +280,7 @@ type ExploreProps = {
278
280
token:string|Promise<string>; // JWT with canExplore: true
279
281
280
282
// Optional
283
+
theme?:'light'|'dark'; // Force light or dark color scheme
281
284
styles?: {
282
285
backgroundColor?:string; // Background color or 'transparent'
283
286
fontFamily?:string; // Font family for all text
@@ -465,6 +468,60 @@ Sets the background for the embedded content. Can be any color value or `'transp
465
468
/>
466
469
```
467
470
471
+
## Light and dark mode
472
+
473
+
Use the `theme` prop to render embedded content in either `'light'` or `'dark'` mode. This is typically driven by the host application's own theme state, so the embedded dashboard, chart, or explore matches the surrounding UI.
474
+
475
+
```tsx
476
+
<Lightdash.Dashboard
477
+
instanceUrl={lightdashUrl}
478
+
token={lightdashToken}
479
+
theme="dark"
480
+
/>
481
+
```
482
+
483
+
The `theme` prop is supported on `Lightdash.Dashboard`, `Lightdash.Chart`, and `Lightdash.Explore`.
484
+
485
+
<Info>
486
+
When `theme` is set, the SDK forces the Mantine color scheme and ignores any user-toggled preference stored in the embed. Omit the prop to let the embed use its default (light) color scheme.
487
+
</Info>
488
+
489
+
### Syncing with your app's theme
490
+
491
+
Pass your app's current theme value directly to the SDK so the embed re-renders when it changes:
When `theme` is set, the embed uses the matching Mantine body background by default. If you also pass `styles.backgroundColor`, your value takes precedence:
513
+
514
+
```tsx
515
+
<Lightdash.Dashboard
516
+
instanceUrl={lightdashUrl}
517
+
token={lightdashToken}
518
+
theme="dark"
519
+
styles={{
520
+
backgroundColor: '#0b0b0f', // Overrides the default dark background
521
+
}}
522
+
/>
523
+
```
524
+
468
525
## Color palettes
469
526
470
527
You can customize the appearance of embedded dashboards using color palettes. Define multiple color palettes in your organization settings, then apply them to embedded dashboards using the `paletteUuid` prop.
0 commit comments