Theme Generator
Use the Theme Generator to customize your theme.Make changes and copy the final output from the bottom of the page.
All changes are applied directly to this site.
Colors
Color Scale
Override Foundational Colors
Override Semantic Colors
New Semantic Colors
Lighting
Import and Export Theme
Simply copy and save it as "my-theme.json".
(It only saves Colors and Lighting data now. Others will be added.)
Typography
Pass custom values to primitives as the first parameter of the createTheme function.
Then, import web font files to your app. Lighthouse doesn't include any font files.
(Dynamic Generator feature of these values is work in progress.)
const primitives = {primaryFontFamily: "system-ui, Helvetica, Arial, sans-serif",}
Sizings / Breakpoints / Z-Index
Pass custom values to overrides as the second parameter of the createTheme function.
Below are the default theme values for each kind.
(Dynamic Generator feature of these values is work in progress.)
const overrides = {sizings: {// 2px scalescale0: "2px",scale100: "4px",scale200: "6px",scale300: "8px",scale400: "10px",scale500: "12px",// 4px scalescale550: "14px",scale600: "16px",scale650: "18px",scale700: "20px",scale750: "22px",scale800: "24px",// 8px scalescale900: "32px",scale1000: "40px",// 4px scalescale1200: "48px",scale1400: "56px",scale1600: "64px",scale2400: "96px",scale3200: "128px",scale4800: "192px",},breakpoints: {small: 320,medium: 600,large: 1080,xLarge: 1200,},zIndex: {drawer: 100,header: 100,overlay: 100,modal: 200,select: 200,alert: 300,},}
Using with Design
Change ThemeSwitcher component's Theme property as "Custom" and Upload "my-theme.json" file to "Theme File" Property.
More information in Start Design.
Using with Code
Locate the "my-theme.json" file to your App's root.
(The below example wrote for next.js, and you can customize it for others.)
More information in Start Code.
import App from "next/app"import { Provider as StyletronProvider } from "styletron-react"import { styletron, debug } from "../styletron"import { createTheme, LighthouseProvider } from "@harborschool/lighthouse"import * as output from './my-theme.json'export default class MyApp extends App {render() {const typography = {primaryFontFamily: 'system-ui, Helvetica, Arial, sans-serif',}const customTheme = generateCustomTheme({tokens: output['default'], // Add imported tokenstypography, // Add your custom font})const { Component, pageProps } = this.propsreturn (<StyletronProvider value={styletron} debug={debug}><LighthouseProvider theme={customTheme}><Component {...pageProps} /></LighthouseProvider></StyletronProvider>)}}let colors, foundation, semantic, newSemantic // declare outsite to share variable to eval()export function generateCustomTheme({ tokens, typography }) {if (tokens) {// Custom Color Scalecolors = tokens.colors.colorScale// Foundational Colorsfoundation = trimStringValues(tokens.colors.colorFoundation)// Semantic Colorssemantic = trimStringValues(tokens.colors.colorSemantic)// New Semantic ColorsnewSemantic = tokens.colors.newColorSemanticconst primitives = {...newSemantic,...typography,}const overrides = {colors: {...foundation,...semantic,},lighting: {...tokens.lighting,},sizings: {},breakpoints: {},zIndex: {},}const customTheme = createTheme(primitives, overrides)return customTheme}}function trimStringValues(obj) {Object.keys(obj).forEach((key) => (obj[key] = isHex(obj[key]) ? obj[key] : eval(obj[key])))return obj}function isHex(value) {return /^#[0-9A-F]{6}$/i.test(value)}
© Lighthouse Design System 2022
Created by
@ruucm