UI: add css prefix by default

This commit is contained in:
Fuma Nama
2024-12-29 08:13:56 +08:00
parent e95be5204a
commit f3298eaee5
5 changed files with 29 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-ui': patch
---
Add css prefix by default
+21 -5
View File
@@ -44,11 +44,7 @@ To enable RTL, set the `dir` prop to `rtl` in body and root provider (required f
import { RootProvider } from 'fumadocs-ui/provider';
import type { ReactNode } from 'react';
export default function RootLayout({
children,
}: {
children: ReactNode;
}): ReactNode {
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en" suppressHydrationWarning>
<body dir="rtl">
@@ -63,6 +59,26 @@ export default function RootLayout({
Fumadocs UI provides some CSS variables for customising the layout.
### Prefix
By default, it has a `fd-` prefix to avoid conflicts with Shadcn UI or your own CSS variables.
You can set or remove the prefix in `createPreset`:
```js
import { createPreset } from 'fumadocs-ui/tailwind-plugin';
/** @type {import('tailwindcss').Config} */
export default {
presets: [
createPreset({
// no prefix
cssPrefix: '',
}),
],
};
```
### Navbar Height
When the default navbar is replaced, the layout may overlap with your new navbar.
@@ -2,10 +2,6 @@ import type { ReactNode } from 'react';
import { HomeLayout } from 'fumadocs-ui/layouts/home';
import { baseOptions } from '@/app/layout.config';
export default function Layout({
children,
}: {
children: ReactNode;
}): React.ReactElement {
export default function Layout({ children }: { children: ReactNode }) {
return <HomeLayout {...baseOptions}>{children}</HomeLayout>;
}
@@ -1,3 +1,4 @@
// @ts-check
import { createPreset } from 'fumadocs-ui/tailwind-plugin';
/** @type {import('tailwindcss').Config} */
+1 -1
View File
@@ -120,7 +120,7 @@ function createTailwindColors(
}
export const docsUi = plugin.withOptions<DocsUIOptions>(
({ cssPrefix = '', preset = 'default', layoutWidth = '100vw' } = {}) => {
({ cssPrefix = 'fd', preset = 'default', layoutWidth = '100vw' } = {}) => {
return ({ addBase, addComponents, addUtilities }) => {
const { light, dark, css } =
typeof preset === 'string' ? presets[preset] : preset;