Skip to main content

Theming

The UI wire includes a flexible theming system based on CSS custom properties (variables). Customize colors, typography, spacing, and more.

Configuration

Pass a theme object to FluxKitProvider:

import { FluxKitProvider } from "@fluxkitdev/ui";

<FluxKitProvider
apiUrl="http://localhost:3000"
theme={{
primaryColor: "#6366f1",
secondaryColor: "#ec4899",
backgroundColor: "#ffffff",
surfaceColor: "#f8f9fa",
textColor: "#1a1a1a",
borderRadius: "8px",
fontFamily: "Inter, system-ui, sans-serif",
fontSize: "16px",
}}
>
{children}
</FluxKitProvider>

Theme Properties

PropertyDefault (Light)Default (Dark)Description
primaryColor#6366f1#818cf8Primary brand color
secondaryColor#ec4899#f472b6Secondary accent color
backgroundColor#ffffff#0f0f0fPage background
surfaceColor#f8f9fa#1a1a1aCard/surface background
textColor#1a1a1a#f0f0f0Primary text color
mutedColor#6b7280#9ca3afMuted/secondary text
borderColor#e5e7eb#374151Border color
borderRadius8px8pxDefault border radius
fontFamilyInter, sans-serifInter, sans-serifBase font family
fontSize16px16pxBase font size
successColor#10b981#34d399Success state color
warningColor#f59e0b#fbbf24Warning state color
errorColor#ef4444#f87171Error state color

Dark Mode

Dark mode is supported out of the box. Use the useColorMode hook to toggle:

import { useColorMode } from "@fluxkitdev/ui";

function ThemeToggle() {
const { colorMode, toggleColorMode } = useColorMode();

return (
<button onClick={toggleColorMode}>
{colorMode === "dark" ? "Light Mode" : "Dark Mode"}
</button>
);
}

Set the default mode:

<FluxKitProvider
apiUrl="http://localhost:3000"
theme={{
defaultColorMode: "dark", // "light" | "dark" | "system"
}}
>

CSS Custom Properties

All theme values are exposed as CSS custom properties for use in your own styles:

.my-component {
color: var(--fk-text-color);
background: var(--fk-surface-color);
border: 1px solid var(--fk-border-color);
border-radius: var(--fk-border-radius);
font-family: var(--fk-font-family);
}

.my-button {
background: var(--fk-primary-color);
color: white;
}

Component-Level Overrides

Override styles for individual components using the sx prop:

import { Button, Card } from "@fluxkitdev/ui";

<Button
sx={{
backgroundColor: "#10b981",
borderRadius: "999px",
padding: "12px 24px",
}}
>
Custom Button
</Button>

<Card sx={{ border: "2px solid var(--fk-primary-color)" }}>
Highlighted Card
</Card>

Extending the Theme

Create a reusable theme configuration:

// theme.ts
import type { ThemeConfig } from "@fluxkitdev/ui";

export const myTheme: ThemeConfig = {
primaryColor: "#2563eb",
secondaryColor: "#7c3aed",
borderRadius: "12px",
fontFamily: '"Poppins", sans-serif',
defaultColorMode: "system",
};
import { FluxKitProvider } from "@fluxkitdev/ui";
import { myTheme } from "./theme";

<FluxKitProvider apiUrl="http://localhost:3000" theme={myTheme}>
{children}
</FluxKitProvider>