diff --git a/www/src/pages/foundations/colors.tsx b/www/src/pages/foundations/colors.tsx index 35a6917f7f..9d08e3b720 100644 --- a/www/src/pages/foundations/colors.tsx +++ b/www/src/pages/foundations/colors.tsx @@ -1,4 +1,4 @@ -import React, { useContext } from 'react'; +import React, { useState, useEffect, useContext } from 'react'; import { graphql } from 'gatsby'; import PropTypes from 'prop-types'; import classNames from 'classnames'; @@ -121,7 +121,16 @@ export interface IColorsPage { // eslint-disable-next-line react/prop-types export default function ColorsPage({ data }: IColorsPage) { const { settings } = useContext(SettingsContext); - const styles = typeof window !== 'undefined' ? getComputedStyle(document.body) : null; + const [styles, setStyles] = useState(null); + + useEffect(() => { + setTimeout(() => { + if (typeof window !== 'undefined') { + const newStyles = getComputedStyle(document.body); + setStyles(newStyles); + } + }, 500); + }, [settings.theme]); parseColors(data.allCssUtilityClasses.nodes); // eslint-disable-line react/prop-types