Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/color-scheme-dark-theme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@strapi/design-system": minor
---

Add CSS `color-scheme` property to improve dark theme support for native browser elements (scrollbars, form controls)
1 change: 1 addition & 0 deletions packages/design-system/src/styles/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ${css`
html {
/* Sets 1rem === 10px */
font-size: 62.5%;
color-scheme: ${({ theme }) => theme.colorScheme};
}

body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ describe('extendTheme', () => {
import { lightTheme, extendTheme } from '@strapi/design-system';

const myCustomTheme = extendTheme(lightTheme, {
colors: /* put the overrides for the colors key */,
colorScheme: /* put the overrides for the colorScheme key */,
colors: /* put the overrides for the colors key */,
shadows: /* put the overrides for the shadows key */,
sizes: /* put the overrides for the sizes key */,
zIndices: /* put the overrides for the zIndices key */,
Expand Down Expand Up @@ -59,7 +60,8 @@ describe('extendTheme', () => {
import { lightTheme, extendTheme } from '@strapi/design-system';

const myCustomTheme = extendTheme(lightTheme, {
colors: /* put the overrides for the colors key */,
colorScheme: /* put the overrides for the colorScheme key */,
colors: /* put the overrides for the colors key */,
shadows: /* put the overrides for the shadows key */,
sizes: /* put the overrides for the sizes key */,
zIndices: /* put the overrides for the zIndices key */,
Expand Down
6 changes: 6 additions & 0 deletions packages/design-system/src/themes/color-scheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const COLOR_SCHEMES = {
LIGHT: 'light',
DARK: 'dark',
} as const;

export type ColorScheme = (typeof COLOR_SCHEMES)[keyof typeof COLOR_SCHEMES];
2 changes: 2 additions & 0 deletions packages/design-system/src/themes/darkTheme/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { DefaultTheme } from 'styled-components';

import { commonTheme } from '../common-theme';
import { COLOR_SCHEMES } from '../color-scheme';

import { darkColorTokenObject } from './dark-colors';
import { darkShadowTokenObject } from './dark-shadows';

export const darkTheme: DefaultTheme = {
colorScheme: COLOR_SCHEMES.DARK,
colors: darkColorTokenObject.color,
shadows: darkShadowTokenObject.shadow,
...commonTheme,
Expand Down
3 changes: 3 additions & 0 deletions packages/design-system/src/themes/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ColorScheme } from './color-scheme';
import { Colors, Shadows } from './colors';
import { CommonTheme } from './common-theme';

export * from './color-scheme';
export * from './lightTheme';
export * from './darkTheme';
export * from './extendTheme';
Expand All @@ -9,4 +11,5 @@ export * from './utils';
export interface StrapiTheme extends CommonTheme {
colors: Colors;
shadows: Shadows;
colorScheme: ColorScheme;
}
2 changes: 2 additions & 0 deletions packages/design-system/src/themes/lightTheme/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { DefaultTheme } from 'styled-components';

import { commonTheme } from '../common-theme';
import { COLOR_SCHEMES } from '../color-scheme';

import { lightColorTokenObject } from './light-colors';
import { lightShadowTokenObject } from './light-shadows';

export const lightTheme: DefaultTheme = {
colorScheme: COLOR_SCHEMES.LIGHT,
colors: lightColorTokenObject.color,
shadows: lightShadowTokenObject.shadow,
...commonTheme,
Expand Down
Loading