
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@ttoss/fsl-theme
Advanced tools
Design token system for the ttoss ecosystem. Separates raw values (core) from stable design meaning (semantic) so components never break when themes change or modes switch. The semantic layer is the public contract β type-safe, mode-agnostic, and consumed directly as CSS custom properties with zero runtime overhead.
pnpm add @ttoss/fsl-theme
| Import | Exports |
|---|---|
@ttoss/fsl-theme | createTheme, darkAlternate, built-in themes (bruttal, corporate, oca, ventures), types (ThemeTokens, ThemeBundle, SemanticTokens, ModeOverride, DeepPartial, ThemeMode) |
@ttoss/fsl-theme/react | ThemeProvider, ThemeHead, ThemeScript, ThemeStyles, useColorMode, useTokens, useResolvedTokens |
@ttoss/fsl-theme/dataviz | withDataviz, useDatavizTokens |
@ttoss/fsl-theme/css | getThemeStylesContent, toCssVars, toCssVarName, toFlatTokens |
@ttoss/fsl-theme/vars | vars, buildVarsMap, type CssVarsMap |
@ttoss/fsl-theme/dtcg | toDTCG (W3C Design Tokens format) |
@ttoss/fsl-theme/runtime | createThemeRuntime, getThemeScriptContent |
ThemeTokens
βββ core β raw primitives (immutable across modes)
βββ semantic β {core.*} references (the public contract; remapped per mode)
Components consume only semantic tokens. Core tokens never change between light and dark β only semantic references remap.
One entry per semantic family. Use vars.* for typed CSS variable references; use the semantic.* path shape below when naming tokens in TypeScript or in discussion.
| Family | Path shape | Leaf value |
|---|---|---|
| colors | semantic.colors.{ux}.{role}.{dimension}.{state} | CSS color |
| spacing | semantic.spacing.inset.{control,surface}.{sm,md,lg} | CSS length |
semantic.spacing.gap.{stack,inline}.{xs,sm,md,lg,xl} | CSS length | |
semantic.spacing.gutter.{page,section} | CSS length / clamp() | |
semantic.spacing.separation.interactive.min | CSS length | |
| text | semantic.text.{display,headline,title,body,label,code}.{lg,md,sm} | TextStyle object |
| sizing | semantic.sizing.hit.{min,base,prominent} | CSS length |
semantic.sizing.icon.{sm,md,lg} | CSS length | |
semantic.sizing.identity.{sm,md,lg,xl} | CSS length | |
semantic.sizing.measure.reading | CSS ch / clamp() | |
semantic.sizing.surface.maxWidth | CSS length | |
semantic.sizing.viewport.{height,width}.full | CSS dvh/dvw | |
| radii | semantic.radii.{control,surface,round} | CSS length |
| border | semantic.border.divider | {width, style} |
semantic.border.outline.{surface,control,selected} | {width, style} | |
| focus | semantic.focus.ring | {width, style, color} |
| elevation | semantic.elevation.surface.{flat,raised,overlay,blocking} | CSS box-shadow |
semantic.elevation.tonal.{flat,raised,overlay,blocking} | CSS color (optional) | |
| opacity | semantic.opacity.{scrim,loading,disabled} | number in (0, 1) |
| overlay | semantic.overlay.scrim | CSS color with alpha |
| motion | semantic.motion.{feedback,emphasis,decorative} | {duration, easing} |
semantic.motion.transition.{enter,exit} | {duration, easing} | |
| zIndex | semantic.zIndex.layer.{base,sticky,overlay,blocking,transient} | integer |
Colors axes (semantic.colors.{ux}.{role}.{dimension}.{state}):
ux β FSL Entity Kind: action Β· input Β· navigation Β· feedback Β· informationalrole β Evaluation: primary Β· secondary Β· accent Β· muted Β· positive Β· caution Β· negativedimension β background Β· border Β· textstate β default Β· hover Β· active Β· focused Β· disabled Β· selected Β· pressedFind the CSS property you are setting, then follow the branch to the leaf.
color / background / border-color / fill β colors
{ux}: action (button, link, CTA) Β· input (field, toggle, checkbox) Β· navigation (tab, menu item, breadcrumb) Β· feedback (alert, banner, toast, progress) Β· informational (card, badge, chip, stat){role}: primary (default for the context) Β· secondary (supporting) Β· accent (brand pop) Β· muted (subdued) Β· positive / caution / negative (outcome valence)background Β· border Β· textdefault Β· hover Β· active Β· focused Β· disabled Β· selected Β· pressedpadding β spacing.inset
spacing.inset.control.{sm|md|lg}spacing.inset.surface.{sm|md|lg}mdgap β spacing.gap
spacing.gap.stack.{xs|sm|md|lg|xl}spacing.gap.inline.{xs|sm|md|lg|xl}spacing.separation.interactive.minpadding on a page or section wrapper β spacing.gutter.{page|section}
font-size / font-family / font-weight / line-height β text
| Element's text function | Token |
|---|---|
| Hero / landing emphasis | text.display.{lg,md,sm} |
| Page or section heading | text.headline.{lg,md,sm} |
| Surface heading (card, panel, dialog) | text.title.{lg,md,sm} |
| Reading prose / description | text.body.{lg,md,sm} |
| UI label / button text / badge | text.label.{lg,md,sm} |
| Code / identifiers / monospace | text.code.{md,sm} |
width / height / min-width / min-height β sizing
sizing.hit.{min|base|prominent}sizing.icon.{sm|md|lg}sizing.identity.{sm|md|lg|xl}max-width in ch) β sizing.measure.readingsizing.surface.maxWidthsizing.viewport.{height|width}.fullborder-radius β radii
radii.controlradii.surfaceradii.roundborder-width / border-style β border (pair with a colors token for the color)
border.dividerborder.outline.surfaceborder.outline.controlborder.outline.selectedoutline (keyboard focus) β focus
{ux}.{role}.border.focused (from colors)focus.ringbox-shadow β elevation.surface
elevation.surface.flatelevation.surface.raisedelevation.surface.overlayelevation.surface.blockingz-index β zIndex.layer
zIndex.layer.basezIndex.layer.stickyzIndex.layer.overlayzIndex.layer.blockingzIndex.layer.transientopacity (whole element) β opacity
opacity.scrimopacity.loadingopacity.disabled{ux}.{role}.{dimension}.disabled from colors β opacity cannot carry contrast guarantees.transition / animation β motion
motion.feedbackmotion.transition.entermotion.transition.exitmotion.emphasismotion.decorativeModal backdrop color β overlay.scrim
Full grammar rules, decision matrices, and anti-patterns live in the family specs. Each file follows the pattern 02-families/{family}.md:
colors Β· spacing Β· typography Β· sizing Β· radii Β· borders Β· elevation Β· opacity Β· motion Β· z-index Β· breakpoints
import { createTheme } from '@ttoss/fsl-theme';
// Default β light base + built-in dark alternate included
const myTheme = createTheme();
// With brand overrides (dark mode still included)
const myTheme = createTheme({
overrides: { core: { colors: { brand: { 500: '#FF0000' } } } },
});
// Custom semantic dark alternate
const myTheme = createTheme({
overrides: { core: { colors: { brand: { 500: '#FF0000' } } } },
alternate: {
semantic: {
colors: {
informational: {
primary: { background: { default: '{core.colors.neutral.900}' } },
},
},
},
},
});
// Single-mode theme (opt out of dark alternate)
const myTheme = createTheme({ alternate: null });
// Inherit from an existing bundle (inherits base + alternate)
const childTheme = createTheme({ extends: myTheme });
alternate is typed ModeOverride = { semantic: DeepPartial<ThemeTokens['semantic']> }. Pass alternate: null for single-mode.
darkAlternate is also exported for direct composition. createTheme() includes it by default.
// main.tsx
import { ThemeProvider } from '@ttoss/fsl-theme/react';
import { myTheme } from './theme';
export const App = () => (
<ThemeProvider theme={myTheme} defaultMode="system">
<YourApp />
</ThemeProvider>
);
ThemeProvider injects CSS Custom Properties via React 19 style hoisting and persists mode to localStorage.
import { useColorMode } from '@ttoss/fsl-theme/react';
const DarkToggle = () => {
const { resolvedMode, setMode } = useColorMode();
return (
<button onClick={() => setMode(resolvedMode === 'dark' ? 'light' : 'dark')}>
{resolvedMode === 'dark' ? 'βοΈ' : 'π'}
</button>
);
};
import { useResolvedTokens } from '@ttoss/fsl-theme/react';
// Non-CSS environments (React Native, canvas) β resolved raw values
const resolved = useResolvedTokens();
// resolved['semantic.colors.action.primary.background.default'] β '#0469E3'
/* CSS β no JS overhead, no re-renders */
.button {
background: var(--tt-colors-action-primary-background-default);
}
import { vars } from '@ttoss/fsl-theme/vars';
// Typed CSS variable references
<div style={{ color: vars.colors.informational.primary.background.default }} />;
vars with custom semantic tokensvars is typed against the default SemanticTokens shape. If your project adds custom families (e.g. a dataviz palette, project-specific component tokens), those leaves won't appear on the default export. Build a typed mirror of your extended shape with the public buildVarsMap helper:
import { createTheme, type SemanticTokens } from '@ttoss/fsl-theme';
import { buildVarsMap, type CssVarsMap } from '@ttoss/fsl-theme/vars';
type MySemanticTokens = SemanticTokens & {
colors: SemanticTokens['colors'] & {
brandX: { primary: { default: string } };
};
};
const myTheme = createTheme({
/* β¦ */
});
export const myVars: CssVarsMap<MySemanticTokens> = buildVarsMap(
myTheme.base
) as CssVarsMap<MySemanticTokens>;
For one-off custom keys, use toCssVarName from @ttoss/fsl-theme/css directly β no extended type required.
ThemeProvider with a theme prop uses React 19 style hoisting to inject CSS into <head> automatically. Only add ThemeScript for flash-prevention:
// app/layout.tsx
import { ThemeScript, ThemeProvider } from '@ttoss/fsl-theme/react';
import { myTheme } from './theme';
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<head>
{/* Flash-prevention only β ThemeProvider handles CSS via React 19 hoisting */}
<ThemeScript defaultMode="system" />
</head>
<body>
<ThemeProvider theme={myTheme} defaultMode="system">
{children}
</ThemeProvider>
</body>
</html>
);
}
Use ThemeHead (script + CSS) without a theme prop on ThemeProvider β or use ThemeHead standalone when
React style hoisting is unavailable:
// app/layout.tsx β for frameworks without React 19 style hoisting
import { ThemeHead, ThemeProvider } from '@ttoss/fsl-theme/react';
import { myTheme } from './theme';
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<head>
{/* Injects flash-prevention script + CSS vars */}
<ThemeHead theme={myTheme} defaultMode="system" />
</head>
<body>
{/* No theme prop β CSS is already in <head> via ThemeHead */}
<ThemeProvider defaultMode="system">{children}</ThemeProvider>
</body>
</html>
);
}
Warning: Do not combine
<ThemeHead theme={...}>with<ThemeProvider theme={...}>. Both inject CSS βThemeHeadvia a plain<style>tag andThemeProvidervia React 19 style hoisting β resulting in duplicate CSS in the document. Use one or the other.
// theme.ts
import { createTheme } from '@ttoss/fsl-theme';
import { withDataviz } from '@ttoss/fsl-theme/dataviz';
export const myTheme = withDataviz(createTheme());
// Consume via CSS vars β no JS overhead
<span style={{ color: `var(--tt-dataviz-color-series-${i + 1})` }}>
{category}
</span>
import { getThemeStylesContent } from '@ttoss/fsl-theme/css';
const css = getThemeStylesContent(myTheme);
// β :root { --tt-* } + :root[data-tt-mode="dark"] { --tt-* (overrides) }
Anchor theme attributes to a specific element instead of <html>:
const rootRef = React.useRef<HTMLDivElement>(null);
<div ref={rootRef}>
<ThemeProvider theme={myTheme} root={rootRef.current ?? undefined}>
<Story />
</ThemeProvider>
</div>;
FAQs
ttoss theme provider for UI.
We found that @ttoss/fsl-theme demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.