When building a Gatsby theme with gatsby-plugin-theme-ui, the documentation states that you can adjust the background color of the body by adding it to your theme object in the nested colors object. This appears to have no effect. Other variables such as fonts and styles are pulling in correctly, but I can't seem to get the background to change other than adjusting it on individual elements. Is there an additional step to get this to work?
Using setInitialMode
and defining a dark mode was able to change the background, but this seems like a hacky solution as I'm not trying to build in theme color switching.
Here is my theme configuration file in the src/
directory:
theme.js
export const theme = {
space: [0, 4, 8, 16, 32],
fonts: {
body: "Alegreya Sans SC, system-ui, sans-serif",
heading: `Archivo Black, system-ui, sans-serif`,
},
fontSizes: [16, 18, 20, 22, 27, 36, 72],
lineHeights: {
body: 1.45,
heading: 1.1,
},
colors: {
background: "blue",
text: "purple",
primary: "purple",
},
sizes: {
default: "90vw",
max: "540px",
},
styles: {
body: {
margin: 0,
padding: 0,
},
h1: {
color: "primary",
fontSize: 6,
fontWeight: "bold",
lineHeight: "heading",
fontFamily: "heading",
},
ul: {
borderTop: "1px solid",
borderColor: "gray.0",
listStyle: "none",
padding: 0,
},
li: {
borderBottom: "1px solid",
borderColor: "gray.1",
padding: 2,
"&:focus-within,&:hover": {
backgroundColor: "gray.0",
},
},
},
}
export default theme
index.js in the src/gatsby-plugin-theme-ui/
directory:
import theme from "../theme"
export default theme
No error messages are created. The background remains with the default color regardless of what color is entered - hex, rgba or otherwise.