Back to Plugins
Swift Colors

Swift Colors

Swift Colors is a simple plugin for exporting color tokens to a Swift color theme.FeaturesMap color tokens in Figma to a type-safe Swift color theme file automatically.Define light and dark mode color behaviour directly from Figma, by organising your color tokens in light and dark mode palettes.How to use1. Prepare your file's color tokensOrganise color styles into a light and dark mode color palette in the Color Styles panel. Figma color styles can be organised in groups by prefixing the color style name with the group name.For example: "Light Mode/Buttons/Primary""Dark Mode/Buttons/Primary"If you don't have a dark mode color palette yet, the plugin will use the light mode palette for dark mode too.2. ExportExport the .swift file to your Xcode project.3. Use in XcodeUse your color theme by calling the desired color token name in your code. For example:button.backgroundColor = Buttons.primary 4. See it in action! If you have defined both a light and dark mode color palette that contains a color style for Buttons.primary, iOS will automatically change between the two variants based on the user's preference.Why it worksThe exported theme file includes an extension on UIColor that automatically adapts to light and dark mode variants based on the current UITraitCollection.

themeiosuicoloriphonexcodecodeexportcolorswift

Plugin Preview

Swift Colors preview

About this plugin

Swift Colors is a simple plugin for exporting color tokens to a Swift color theme.FeaturesMap color tokens in Figma to a type-safe Swift color theme file automatically.Define light and dark mode color behaviour directly from Figma, by organising your color tokens in light and dark mode palettes.How to use1. Prepare your file's color tokensOrganise color styles into a light and dark mode color palette in the Color Styles panel. Figma color styles can be organised in groups by prefixing the color style name with the group name.For example: "Light Mode/Buttons/Primary""Dark Mode/Buttons/Primary"If you don't have a dark mode color palette yet, the plugin will use the light mode palette for dark mode too.2. ExportExport the .swift file to your Xcode project.3. Use in XcodeUse your color theme by calling the desired color token name in your code. For example:button.backgroundColor = Buttons.primary 4. See it in action! If you have defined both a light and dark mode color palette that contains a color style for Buttons.primary, iOS will automatically change between the two variants based on the user's preference.Why it worksThe exported theme file includes an extension on UIColor that automatically adapts to light and dark mode variants based on the current UITraitCollection.

Plugin Details

Version1
CreatedFebruary 13, 2022
Last UpdatedFebruary 13, 2022
CategorySoftware development
CreatorEmil Baehr
Stats476 installs, 39 likes
PricingFree

Technical Details

  • API:1.0.0
  • UI:dist/ui.html
  • main:dist/code.js
  • Editor Types:
    figma