Skip to content

Instantly share code, notes, and snippets.

@mfix22
Created May 8, 2019 20:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfix22/f2e9f4f08c683cc6520f51342b18bf49 to your computer and use it in GitHub Desktop.
Save mfix22/f2e9f4f08c683cc6520f51342b18bf49 to your computer and use it in GitHub Desktop.
CSS variables in `styled-components`
import {createGlobalStyle} from 'styled-components';
// This becomes the source of truth for the application
export default const GlobalStyle = createGlobalStyle`
:root {
--primary: cyan;
--text: #506784;
--borders: #EBF0F8;
--page-background: transparent;
--nav-background: white;
/* add more colors */
--font-primary: "Helvetica Neue", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
--font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
--x1: 4px;
--x2: 8px;
--x3: 16px;
--x4: 24px;
--x5: 32px;
--x6: 64px;
--f1: 0.75rem;
--f2: 0.875rem;
--f3: 1rem;
--f4: 1.25rem;
--f5: 1.5rem;
--f6: 2rem;
/* add more variables to fill our your system */
}
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment