Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Demo code of building color palette system in SwiftUI
struct BaseColor {
/// dynamic color sets (with dark and light mode)
let contrastPrimary = Color("contrastPrimary")
let themePrimary = Color("themePrimary")
/// staic color sets (not updating along with color mode)
let darkPrimary = Color("darkPrimary")
let lightPrimary = Color("lightPrimary")
struct TokenColor {
let baseColor = BaseColor()
let textDefault: Color!
let textTheme: Color!
let textLight: Color!
let buttonTheme: Color!
let buttonContrast: Color!
let backgroundDefault: Color!
let backgroundTheme: Color!
init() {
/// themePrimary
self.textTheme = baseColor.themePrimary
self.buttonTheme = baseColor.themePrimary
self.backgroundTheme = baseColor.themePrimary
/// contrastPrimary
self.buttonContrast = baseColor.contrastPrimary
self.textDefault = baseColor.contrastPrimary
self.backgroundDefault = baseColor.contrastPrimary
/// lightPrimary
self.textLight = baseColor.lightPrimary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.