Penpot plugins API
    Preparing search index...

    Interface TokenCatalog

    The collection of all tokens in a Penpot file's library.

    Tokens are contained in sets, that can be marked as active or inactive to control the resolved value of the tokens.

    The active status of sets can be handled by presets named Themes.

    interface TokenCatalog {
        themes: TokenTheme[];
        sets: TokenSet[];
        addTheme(group: { group: string; name: string }): TokenTheme;
        addSet(name: { name: string }): TokenSet;
        getThemeById(id: string): TokenTheme | undefined;
        getSetById(id: string): TokenSet | undefined;
    }
    Index

    Properties

    themes: TokenTheme[]

    The list of themes in this catalog, in creation order.

    sets: TokenSet[]

    The list of sets in this catalog, in the order defined by the user. The order is important because then same token name exists in several active sets, the latter has precedence.

    Methods

    • Creates a new TokenTheme and adds it to the catalog.

      Parameters

      • group: { group: string; name: string }

        The group name of the theme (can be empty string).

      Returns TokenTheme

      Returns the created TokenTheme.

    • Creates a new TokenSet and adds it to the catalog.

      Parameters

      • name: { name: string }

        The name of the set (required). It may contain a group path, separated by /.

      Returns TokenSet

      Returns the created TokenSet.

    • Retrieves a theme.

      Parameters

      • id: string

        the id of the theme.

      Returns TokenTheme | undefined

      Returns the theme or undefined if not found.

    • Retrieves a set.

      Parameters

      • id: string

        the id of the set.

      Returns TokenSet | undefined

      Returns the set or undefined if not found.