主題
為 Fumadocs UI 新增主題
使用方式
注意只支援 Tailwind CSS v4:
@import 'tailwindcss';
@import 'fumadocs-ui/css/neutral.css';
@import 'fumadocs-ui/css/preset.css';
/* path of `fumadocs-ui` relative to the CSS file */
@source '../node_modules/fumadocs-ui/dist/**/*.js';
Preflight 變更
透過使用 Tailwind CSS 外掛或預先建置的樣式表,你的預設邊框、文字和背景顏色將會被變更。
明/暗模式
Fumadocs 透過 next-themes
支援明/暗模式,它包含在 Root Provider 中。
請參見 Root Provider 了解更多資訊。
RTL 佈局
支援 RTL(由右到左)佈局。
要啟用 RTL,請在 body 和 root provider(Radix UI 需要)中將 dir
屬性設定為 rtl
。
import { RootProvider } from 'fumadocs-ui/provider';
import type { ReactNode } from 'react';
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en" suppressHydrationWarning>
<body dir="rtl">
<RootProvider dir="rtl">{children}</RootProvider>
</body>
</html>
);
}
前綴
Fumadocs UI 有自己的顏色、動畫和工具程式。
預設情況下,它新增了 fd-
前綴,以避免與 Shadcn UI 或你自己的 CSS 變數衝突。
你可以透過新增一些別名來使用它們,而無需前綴:
@theme {
--color-primary: var(--color-fd-primary);
}
你可以將其與 CSS 媒體查詢一起使用,實現響應式設計。
佈局寬度
使用 CSS 變數自訂文件佈局的最大寬度。
:root {
--fd-layout-width: 1400px;
}
Tailwind CSS 預設
Tailwind CSS 預設引入了新的顏色和額外的工具程式,包括 fd-steps
。
主題
它開箱即用地提供了許多主題,你可以選擇一個你喜歡的。
@import 'fumadocs-ui/css/<theme>.css';
/* Example */
@import 'fumadocs-ui/css/black.css';
顏色
設計系統的靈感來自 Shadcn UI,你可以使用 CSS 變數輕鬆自訂顏色。
:root {
--color-fd-background: hsl(0, 0%, 100%);
}
.dark {
--color-fd-background: hsl(0, 0%, 0%);
}
排版
我們有一個內建外掛,它是從 Tailwind CSS Typography 衍生而來的。
該外掛新增了一個 prose
類別和變體來自訂它。
<div className="prose">
<h1>Good Heading</h1>
</div>
該外掛僅與 Fumadocs UI 的 MDX 元件一起使用,它可能與 @tailwindcss/typography
衝突。
如果你需要使用 @tailwindcss/typography
而不是預設外掛,請設定類別名稱選項以避免衝突。