Skip to Content

theme.tsx

app/theme.tsx holds the app’s look (primary color, radius, density, dark mode, icon set, antd tokens) in one APP_THEME object the owner can edit.

app/ ├── theme.tsx # APP_THEME ├── layout.tsx # ConfigProvider gets the theme automatically └── orders/page.tsx # reads tokens with theme.useToken()

What it does

manh.run applies APP_THEME to the app’s outermost ConfigProvider, so every antd and pro-components component and every token-based Tailwind class (bg-surface, text-primary) follows it. The owner edits it under Design in the project sidebar; that editor reads and writes this file.

Exports

APP_THEME, a JSON value between the markers /* ft-theme */ and /* /ft-theme */:

  • colorPrimary: the primary color. Pick one that keeps white text readable (contrast ≥ 4.5:1).
  • borderRadius: corner radius in px.
  • compact: true for a dense UI.
  • dark: true for dark mode.
  • icons (optional): "antd" (default) or "lucide".
  • antd (optional): { token, components }, the same shape as antd’s theme editor, for every other token such as fontFamily.
  • kit (optional): the theme kit the owner picked in the theme editor (clean, minimal, corporate, warm, fresh, nature, rose, luxe, night). A kit writes the page, card, border and text colors into antd.token, so app code should not set those colors again.

Example

app/theme.tsx
export const APP_THEME: { colorPrimary: string; borderRadius: number; compact: boolean; dark: boolean } = /* ft-theme */ {"colorPrimary":"#0f766e","borderRadius":8,"compact":false,"dark":false} /* /ft-theme */;
app/components/KpiCard.tsx
import { Card, theme } from "antd"; export function KpiCard({ label, value }: { label: string; value: string }) { const { token } = theme.useToken(); return ( <Card> <div style={{ color: token.colorTextSecondary }}>{label}</div> <div style={{ color: token.colorPrimary, fontSize: 24 }}>{value}</div> </Card> ); }

Good to know

  • Keep both ft-theme markers and valid JSON, or the owner can no longer edit the theme.
  • No hex codes in style. Read colors with theme.useToken() or token-based Tailwind classes; check warns code.hardcoded-color and code.tw-hardcoded-neutral.
  • A layout ConfigProvider without theme inherits APP_THEME. A layout that sets its own theme must read APP_THEME.
  • With icons: "lucide", keep importing icons from @ant-design/icons by antd name; manh.run swaps in the Lucide twin. Don’t import lucide-react.
  • Token names antd doesn’t know warn theme.unknown-token.
  • Use only icon names that exist in @ant-design/icons. A made-up name like LeafOutlined renders as ”?” and check reports ui.unknown-icon.

Next steps

Last updated