Skip to main content

themes API

The themes api allows you to access the current user's theme and utilize the color tokens accordingly.

Usage

import { themes } from '@replit/extensions';

Methods

themes.getCurrentTheme

Returns all metadata on the current theme including syntax highlighting, description, HSL, token values, and more.

getCurrentTheme(): Promise<ThemeVersion>

themes.getCurrentThemeValues

Returns the current theme's global token values.

getCurrentThemeValues(): Promise<ThemeValuesGlobal>

themes.onThemeChange

Fires the callback parameter function with the updated theme when the user's theme changes.

onThemeChange(callback: OnThemeChangeListener): Promise<DisposerFunction>

themes.onThemeChangeValues

Fires the callback parameter function with the updated theme values when the user's theme changes.

onThemeChangeValues(callback: OnThemeChangeValuesListener): Promise<DisposerFunction>

Types

ColorScheme

Enumerated Color Scheme

PropertyType

CustomTheme

Custom Theme GraphQL type

PropertyType
authorUser
colorSchemeColorScheme
hasUnpublishedChangesboolean
idnumber
isCurrentUserThemeAuthorboolean
isInstalledByCurrentUserboolean
latestThemeVersionThemeVersion
numInstalls?number
slug?string
status?"private" │ "public"
title?string

ThemeEditorSyntaxHighlighting

Theme Editor Syntax Highlighting

PropertyType
__typenamestring
tagsThemeSyntaxHighlightingTag[]
valuesThemeSyntaxHighlightingModifier

ThemeSyntaxHighlightingModifier

Theme Syntax Highlighting Modifier

PropertyType
color?string
fontSize?string
fontStyle?string
fontWeight?string
textDecoration?string

ThemeSyntaxHighlightingTag

Theme Syntax Highlighting Tag

PropertyType
__typenamestring
modifiersnull │ string[]
namestring

ThemeValues

Both global and editor theme values

PropertyType
__typename?string
editorThemeValuesEditor
globalThemeValuesGlobal

ThemeValuesEditor

Editor Theme Values, an array of ThemeEditorSyntaxHighlighting

PropertyType
syntaxHighlightingThemeEditorSyntaxHighlighting[]

ThemeValuesGlobal

Global theme values interface

PropertyType
__typename?string
accentNegativeDefaultstring
accentNegativeDimmerstring
accentNegativeDimmeststring
accentNegativeStrongerstring
accentNegativeStrongeststring
accentPositiveDefaultstring
accentPositiveDimmerstring
accentPositiveDimmeststring
accentPositiveStrongerstring
accentPositiveStrongeststring
accentPrimaryDefaultstring
accentPrimaryDimmerstring
accentPrimaryDimmeststring
accentPrimaryStrongerstring
accentPrimaryStrongeststring
backgroundDefaultstring
backgroundHigherstring
backgroundHigheststring
backgroundOverlaystring
backgroundRootstring
blackstring
blueDefaultstring
blueDimmerstring
blueDimmeststring
blueStrongerstring
blueStrongeststring
blurpleDefaultstring
blurpleDimmerstring
blurpleDimmeststring
blurpleStrongerstring
blurpleStrongeststring
brownDefaultstring
brownDimmerstring
brownDimmeststring
brownStrongerstring
brownStrongeststring
foregroundDefaultstring
foregroundDimmerstring
foregroundDimmeststring
greenDefaultstring
greenDimmerstring
greenDimmeststring
greenStrongerstring
greenStrongeststring
greyDefaultstring
greyDimmerstring
greyDimmeststring
greyStrongerstring
greyStrongeststring
limeDefaultstring
limeDimmerstring
limeDimmeststring
limeStrongerstring
limeStrongeststring
magentaDefaultstring
magentaDimmerstring
magentaDimmeststring
magentaStrongerstring
magentaStrongeststring
orangeDefaultstring
orangeDimmerstring
orangeDimmeststring
orangeStrongerstring
orangeStrongeststring
outlineDefaultstring
outlineDimmerstring
outlineDimmeststring
outlineStrongerstring
outlineStrongeststring
pinkDefaultstring
pinkDimmerstring
pinkDimmeststring
pinkStrongerstring
pinkStrongeststring
purpleDefaultstring
purpleDimmerstring
purpleDimmeststring
purpleStrongerstring
purpleStrongeststring
redDefaultstring
redDimmerstring
redDimmeststring
redStrongerstring
redStrongeststring
tealDefaultstring
tealDimmerstring
tealDimmeststring
tealStrongerstring
tealStrongeststring
whitestring
yellowDefaultstring
yellowDimmerstring
yellowDimmeststring
yellowStrongerstring
yellowStrongeststring

ThemeVersion

Theme Version GraphQL type

PropertyType
__typename?string
customTheme?CustomTheme
description?string
huenumber
idnumber
lightnessnumber
saturationnumber
timeUpdated?string
values?ThemeValues

ColorScheme

Enumerated Color Scheme

Dark = 'dark'
Light = 'light'

DisposerFunction

A cleanup/disposer function (void)

() => void

OnThemeChangeListener

Fires with the new theme data when the current theme changes

(theme: ThemeVersion) => void
Was this helpful?