Skip to content

Settings Api

Getting or setting any value on the settings api will get/set the value of the setting with the corresponding id, if it exists.

listen(key, callback): () => void

Fires a callback whenever a setting changes

ParameterType
keystring
callback(value, remote) => void

Function

A function to stop listening


create(description): void

Initializes the settings menu for the script

ParameterType
description(PluginSetting | SettingGroup)[]

All settings (aside from “custom” and “group”) inherit these properties.

PropertyTypeDescription
idstringThe key which can be used to access the value of setting
titlestringThe title of the setting in the settings menu
description?stringA description for the setting in the settings menu
default?TThe default value of the setting
onChange?(value, remote) => voidA callback that fires when the setting changes
SettingTypeOptionsNotes
dropdownstringoptions: { label: string; value: string }[]
allowNone?: boolean
multiselectstring[]options: { label: string; value: string }[]
numbernumbermin?: number
max?: number
step?: number
toggleboolean
textstringplaceholder?: string
maxLength?: number
slidernumbermin: number
max: number
step?: number
ticks?: number[]
formatter?: (value: number) => string
Ticks are placed at the start and end by default
radiostringoptions: { label: string; value: string }[]
colorstringrgba?: booleanWhen rgba is true, the value takes the form rgba(100,120,140,0.5). Otherwise it is a hex code.
customanyrender: SettingRenderer
customsectionanyrender: SettingRendererCustom sections do not have a built-in title or description.
groupN/Atitle: string
settings: PluginSetting[]

The “custom” and “customsection” settings require a render function, which looks like so: (container: HTMLElement, currentValue: any, update: (newValue: any) => void) => (() => void) | void. The function can return a callback to be run when the element is unmounted.

void