Skip to content

feat(theme): allow deployments to register extra theme tokens - #42874

Open
gabotorresruiz wants to merge 1 commit into
apache:masterfrom
gabotorresruiz:feat/extra-theme-tokens
Open

feat(theme): allow deployments to register extra theme tokens#42874
gabotorresruiz wants to merge 1 commit into
apache:masterfrom
gabotorresruiz:feat/extra-theme-tokens

Conversation

@gabotorresruiz

@gabotorresruiz gabotorresruiz commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

Superset's theme system supports custom tokens beyond Ant Design's (for example brandLogoUrl, echartsOptionsOverrides, and the label* / button* tokens in SupersetSpecificTokens). Deployments, white-label distributors, and custom chart plugins legitimately define their own tokens and consume them via useTheme. Today the theme editor validates token names against a fixed allowlist (antdTokenNames.ts), so any such deployment-specific token is flagged as an "Unknown token" warning with no supported way to register it.

This adds an EXTRA_THEME_TOKENS config that lets a deployment register extra custom token names. It follows the exact pattern already used for EXTRA_CATEGORICAL_COLOR_SCHEMES / EXTRA_SEQUENTIAL_COLOR_SCHEMES: a config default, shipped to the frontend in the common bootstrap payload, and merged into the theme editor's valid-token set at runtime.

TESTING INSTRUCTIONS

  1. Set EXTRA_THEME_TOKENS = ["myBrandToken"] in superset_config.py.
  2. Open the theme editor and add "myBrandToken": "..." inside a theme's token object.
  3. Confirm no "Unknown token" warning is shown for it (an unregistered token like "foo" still warns).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.37%. Comparing base (fe06ebe) to head (b60e693).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #42874   +/-   ##
=======================================
  Coverage   66.37%   66.37%           
=======================================
  Files        2857     2857           
  Lines      161048   161053    +5     
  Branches    37046    37049    +3     
=======================================
+ Hits       106892   106898    +6     
+ Misses      52141    52139    -2     
- Partials     2015     2016    +1     
Flag Coverage Δ
hive 38.26% <100.00%> (+<0.01%) ⬆️
javascript 73.20% <100.00%> (+<0.01%) ⬆️
mysql 57.75% <100.00%> (+<0.01%) ⬆️
postgres 57.79% <100.00%> (-0.01%) ⬇️
presto 40.22% <100.00%> (+<0.01%) ⬆️
python 59.19% <100.00%> (-0.01%) ⬇️
sqlite 57.42% <100.00%> (+<0.01%) ⬆️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Custom theme tokens consumed by a deployment or plugin via useTheme (beyond
Ant Design and Superset's built-in tokens) are flagged as unknown in the theme
editor, with no supported way to register them. Add an EXTRA_THEME_TOKENS
config, shipped in the common bootstrap payload and merged into the theme
editor's valid-token set, mirroring EXTRA_CATEGORICAL_COLOR_SCHEMES. Empty by
default, so behavior is unchanged unless a deployment opts in.
@gabotorresruiz
gabotorresruiz force-pushed the feat/extra-theme-tokens branch from 855f5e8 to b60e693 Compare August 7, 2026 14:05
@gabotorresruiz
gabotorresruiz marked this pull request as ready for review August 7, 2026 15:04
@dosubot dosubot Bot added the global:theming Related to theming Superset label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

global:theming Related to theming Superset size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant