Tailwind CSS Integration#
Dify's web/ frontend uses Tailwind CSS v4 with a CSS-first configuration model — there is no tailwind.config.ts . All configuration, theme tokens, and plugin wiring live in web/app/styles/tailwind-core.css.
The migration from v3 to v4 landed in PR #34415 and touched 900+ files.
Build Pipeline#
| Layer | File | Role |
|---|---|---|
| PostCSS | web/postcss.config.js | Single plugin: @tailwindcss/postcss (replaces separate tailwindcss + autoprefixer) |
| Vite | web/vite.config.ts | @tailwindcss/vite plugin, loaded only for non-test / non-Storybook builds |
The old autoprefixer dependency was dropped because @tailwindcss/postcss bundles it .
CSS Entry Point: tailwind-core.css#
web/app/styles/tailwind-core.css is the single source of truth for all Tailwind setup:
- Layer order declared at the top via
@layer theme, base, components, utilities - Selective Tailwind imports — only
tailwindcss/theme.cssandtailwindcss/utilities.cssare imported, skipping built-in preflight in favor of a localpreflight.css - Design system —
@langgenius/dify-ui/styles.cssis imported to bring in the shared palette, semantic tokens, and light/dark themes - Theme extensions —
@theme { }block adds custom breakpoints (mobile,tablet,pc,2k) and aspin-slowanimation - Runtime gradient tokens —
@theme inline { }maps CSS variables (resolved frommanual-light.css/manual-dark.css) to Tailwind's--background-image-*namespace - Component CSS —
@layer components { }adds utilities like.text-gradientand Shiki line-number styles
Custom Plugins#
Two Tailwind plugins are registered via @plugin directives in tailwind-core.css . Both are TypeScript modules in web/app/styles/plugins/:
icons.ts— wraps@egoist/tailwindcss-iconswith Heroicons, Remix Icon (ri), and two custom Iconify sprite collections (custom-public,custom-vender)typography.ts— wraps@tailwindcss/typographyand injects Dify's prose color tokens via the plugin'sconfigmerge API
v3 → v4 Migration Summary#
What was removed or replaced :
| Removed (v3) | Replaced by (v4) |
|---|---|
tailwind.config.ts / tailwind-common-config.ts | tailwind-core.css CSS-first config |
tailwind-css-plugin.ts (PostCSS-JS converter) | @plugin directive in CSS |
tailwindcss + autoprefixer in PostCSS | @tailwindcss/postcss |
postcss-js dependency | — (no longer needed) |
| Tailwind v3 package | tailwindcss v4 + @tailwindcss/vite |
The deleted tailwind-css-plugin.ts used postcss-js to convert CSS files into PostCSS objects for Tailwind IntelliSense — this workaround is unnecessary in v4's CSS-first model .