← All Articles
Design Guides·3 min read

How to Export a Photo Palette as CSS Variables or SwiftUI Colours

Move ColorPicker swatches into a real project, give the colours meaningful names, and check the generated code before using it.

In this article
Watch the walkthroughTurn a Photo Palette into CSS Variables and a Small Website

A saved palette becomes more useful when it reaches the project you are building. ColorPicker can copy colours as CSS variables, SwiftUI, or UIKit code, and export JSON for another workflow.

I treat the generated output as the handoff point: the values are ready to copy, then the project needs names and roles that make sense to the people maintaining it.

Prepare the palette first

Choose the swatches you intend to use and check their order. If you still have twenty experimental colours, narrow the collection before copying code. Sequential names are easier to interpret when the palette is deliberate.

For extracting candidates from a photo, start with the palette extraction guide.

Open Export Palette

Use Export for the current palette. In Developer Code Export, choose CSS Variables, SwiftUI, or UIKit. Check the preview, then use the corresponding Copy action.

ColorPicker Export Palette sheet with CSS Variables selected, generated code, and a copy button
The export sheet previews the selected code format before copying it.

Developer code and JSON exports require lifetime Pro or an available export credit. A rewarded ad can earn one credit; each code copy or JSON export uses one. Sharing a palette image and copying all HEX codes are free options.

Use CSS variables as a first handoff

The app creates variables such as --color-1. In a real stylesheet, I would keep the extracted values together and add semantic names for the jobs they do.

:root {
  /* Illustrative colors, not the screenshot’s exact export. */
  --color-1: #F7E8CC;
  --color-2: #263D2D;
  --color-3: #CC5A2A;

  --page-background: var(--color-1);
  --text-color: var(--color-2);
  --accent-color: var(--color-3);
}

.sample-card {
  background: var(--page-background);
  color: var(--text-color);
  border: 2px solid var(--accent-color);
}

Separating raw values from roles means you can change a theme without searching for every place a particular HEX code appears.

Put SwiftUI declarations inside a type

The SwiftUI export contains static colour declarations. Place them inside an appropriate type or extension rather than pasting static let at the top level of a file.

ColorPicker export sheet with SwiftUI selected and static colour declarations
SwiftUI export produces declarations you can place in a project type. Review the names before using them throughout an app.
import SwiftUI

enum ProjectPalette {
    // Illustrative value; use your actual exported components.
    static let background = Color(
        red: 247.0 / 255.0,
        green: 232.0 / 255.0,
        blue: 204.0 / 255.0
    )
}

// In a view: .background(ProjectPalette.background)

Rename generic colours to project roles once you know how they will be used. Keep raw swatches if you also need the source palette for future reference.

Check the result where it will appear

Render a small component and inspect it in light and dark appearances if both are supported. Check text contrast, disabled states, borders, and controls. Exporting a pleasing photo palette does not create a complete accessible design system.

If you use JSON, inspect the exported structure before writing an importer. If you use a copied HEX list, confirm the values and order after pasting.

Keep the source and the destination connected

Name the palette for the project and keep a note of its source photo. That makes a later request—“which green did we use?”—easier to answer than an unexplained list of numbers.

ColorPicker’s app page covers current features. If the source image needs conversion first, my format-conversion walkthrough is a useful starting point.

Was this helpful?
VOW1 studio logo
Danish Khan

I build the apps at VOW1 and write these guides to help you use them. More about me.

ColorPickerGraphics & Design
App Store