Skip to content
TokenFlight SDK

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 →

index.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>
app.js
import { TokenFlightWidget } from '@tokenflight/swap';
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.

widget.setTheme('light');
widget.setTheme('dark');
widget.setTheme('auto');
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",
},
},
});
widget.setCustomColors({
"--tf-primary": "#FF6B00",
"--tf-bg": "#1A1A2E",
"--tf-text": "#FFFFFF",
"--tf-border": "#2A2A4A",
});
<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>
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.