Skip to content

Theming & Custom Colors

TokenFlight ships with light, dark, and auto themes. You can further override colors via config.customColors, setCustomColors(), or host CSS variables.

Try the interactive Playground →

Built-in Themes

Declarative

html
<tokenflight-widget theme="dark" to-token="eip155:8453:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" trade-type="EXACT_OUTPUT" amount="100"></tokenflight-widget>
<tokenflight-widget theme="light" to-token="eip155:8453:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" trade-type="EXACT_OUTPUT" amount="100"></tokenflight-widget>
<tokenflight-widget theme="auto" to-token="eip155:8453:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" trade-type="EXACT_OUTPUT" amount="100"></tokenflight-widget>

Imperative

js

const widget = new TokenFlightWidget({
  container: '#widget',
  config: {
    toToken: { chainId: 8453, address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' },
    tradeType: 'EXACT_OUTPUT',
    amount: '100',
    theme: 'auto',
  },
});

widget.initialize();

auto follows prefers-color-scheme and updates when the system theme changes.

Switching at Runtime

js
widget.setTheme('light');
widget.setTheme('dark');
widget.setTheme('auto');

Custom Color Overrides

Via Config

js
const widget = new TokenFlightWidget({
  container: '#widget',
  config: {
    toToken: { chainId: 8453, address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' },
    tradeType: 'EXACT_OUTPUT',
    amount: '100',
    theme: 'dark',
    customColors: {
      "--tf-primary": "#FF6B00",
      "--tf-bg": "#1A1A2E",
    },
  },
});

Via Runtime Method

js
widget.setCustomColors({
  "--tf-primary": "#FF6B00",
  "--tf-bg": "#1A1A2E",
  "--tf-text": "#FFFFFF",
  "--tf-border": "#2A2A4A",
});

Via Host CSS Variables

html
<tokenflight-widget
  theme="dark"
  to-token="eip155:8453:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
  trade-type="EXACT_OUTPUT"
  amount="100"
  style="--tf-accent:#FF6B00; --tf-bg:#1A1A2E; --tf-text:#FFFFFF;"
></tokenflight-widget>

Named Color Keys

KeyCSS VariableDescription
primary--tf-accentButtons, links, active states
background--tf-bgMain background
textPrimary--tf-textPrimary text
textSecondary--tf-text-secondaryLabels, hints
border--tf-borderBorders, dividers
success--tf-successSuccess states
error--tf-errorError states
warning--tf-warningWarning states

See Styling & Customization for font-size variables and ::part() selectors.