Theme UI has built-in color mode support that makes it straightforward to add a dark mode to your Gatsby project. You can use the useColorMode hook to retrieve the active color palette and set it to a predefined dark color palette.
useColorMode