Themes

Create theme styles for dark/light modes

Each app project comes with a default 'Draftbit' theme, which you can rename, where you can configure how colors and typography are applied to your app's UI. Start from one of the predefined themes or build from scratch and create as many custom themes as you like. Access and manage your themes using the Styles & Colors option in the Left Bar of the Builder.

All changes to your theme can be previewed live as they're made in the preview panel on the right side. There you can also select the device and which Screen to preview as you tweak your theme.

While building your app in Draftbit and using either the previews within the Builder or physical devices, you can preview your app with different themes and switch between dark/light modes from the Top Bar of the Builder.

Using the Change Theme Action you can allow your app users to change the theme which is applied to your app's UI - for example if you'd like to let your users customize their experience from a 'Preferences' Screen.

Theme Gallery

The Theme Gallery features several pre-configured themes that are ready to use out-of-the-box or as a starting point. You can click on a theme to preview how your Screens will look using the selected theme and choose to view details or import into your app project to further customize if you like.

Theme Colors

Each theme has named colors for both dark and light modes. When the device is set to dark mode in a live app, or you have switched to dark mode in the Builder during development, the dark colors will be applied anywhere your theme colors are used to style your app UI. Dark colors will always fallback to light colors when not specified.

Colors from all the Base Palettes and any Custom Palettes you've configured are available to select from when defining your app's theme colors.

Brand Colors

These colors represent your company or brand and should be used to distinguish your app from other similair apps in your industry.

Color NameDescription
PrimaryThe main color that represents your brand, used for primary actions and highlights.
SecondaryA complementary color to the primary, often used for secondary actions or emphasis.
TertiaryAn additional color for nuanced UI elements or subtle highlights.
AccentA pop of color to draw attention to specific elements or features.

Typography Colors

These colors affect the different types of text and typography of your app.

Color NameDescription
StrongThe boldest text color, used for important headers or standout text elements.
MediumA slightly less bold text color for subheadings or prominent supporting text.
NormalThe default text color for standard body text throughout your app.
LightA lighter text color for secondary or less emphasized content.
InfoA color used for informational or neutral messages within your app's typography.
SuccessA color used to indicate success or positive outcomes in text.
WarningA color used to signal warnings or caution in text.
DangerA color used to represent errors or critical alerts in text.

Background Colors

These colors affect the different types of backgrounds of your app.

Color NameDescription
BaseThe background color applied to app Screens by default
BrandThe background color that reinforces your brand identity across the app.
InfoA background color for informational or neutral sections of the app.
SuccessA background color to highlight success or positive states.
WarningA background color to caution users or indicate a warning state.
DangerA background color for error messages or critical states.

Foreground Colors

These colors affect the different types of foregrounds of your app.

Color NameDescription
BaseThe base foreground color applied to some components by default
BrandThe foreground color that reflects your brand identity in UI elements.
InfoA foreground color for informational or neutral UI elements.
SuccessA foreground color to signify success or positive actions.
WarningA foreground color to indicate warnings or cautionary elements.
DangerA foreground color for error indicators or critical elements.

Border Colors

These colors affect the different types of borders of your app.

Color NameDescription
BaseThe base border color applied to some components by default
BrandThe border color that aligns with your brand identity for consistent styling.
InfoA border color for informational or neutral boundaries.
SuccessA border color used to indicate success or positive interactions.
WarningA border color to signal warnings or cautionary elements.
DangerA border color for errors or critical boundaries.

Theme Typography

In addition to defining colors for each theme, you can also define typography styles. Each named typography style can be applied to any component which supports Typography props in the Styles panel. All the common styles are available such as H1-H6, Subtitle, Body, Button, etc.

PropertyDescription
StyleThe name of the typography style as it appears in the theme style dropdown in the Typography section of the Styles panel for compatible components
Font FamilyThe font family to use for the typography style. Draftbit supports Google Fonts
WeightThe weight of the font for the typography style. Options will vary depending on the selected Font Family
SizeThe size of the font for the typography style
Line HeightThe line height of the font for the typography style
Letter SpacingThe letter spacing of the font for the typography style

Theme Settings

PropertyDescription
NameThe name of the theme
Default ThemeSet the theme as the default for the app

Applying Theme Styles

Once you have your theme's colors and typography settings defined, you can then choose from the theme's styles when customizing the components in your app's UI.

Colors

Theme colors are available in all color selectors along with the colors in the Base and Custom Palettes. You can choose them when applying color styles to components in your app.

Any color props in the Styles panel which use a theme value will update according to the theme you have selected for previewing. So, if in 'ThemeOne' you have the Brand background color set to Red and in 'ThemeTwo' it's set to Blue, any components that use the Brand background color will update automatically to use the color defined in the selected theme.

Typography

The Typography section in the Styles panel of compatible components includes a selector to choose a base typography Style from the theme's typography settings. This will apply the typography style's default configuration, however you can still override these by setting individual typography props on the component.

Any typography props which use a theme value will update according to the theme you have selected for previewing. So, if in 'ThemeOne' you have the Heading 1 set to use the Inter font family and in 'ThemeTwo' it's set to use Roboto, any components that use the Heading 1 will update automatically to use the typography settings defined in the selected theme.

Themes in Custom Code

You can access the themes and color palettes from Custom Files. They are stored in /themes. Assuming your file is in the /custom-files directory it would look like this:

import * as draftbitThemeObj from '../themes/DraftbitDefault';
import * as palettesObj from '../themes/palettes';

export const logThemeData = () => {
    console.log(draftbitThemeObj)
    console.log(palettesObj)
}

Substitute the name of your theme in place ofDraftbitDefault