tailwind.config.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import type { Config } from "tailwindcss";
  2. import plugin from "tailwindcss/plugin";
  3. import { getColorPalettes } from "./src/styles/theme/antd/css-variables";
  4. export default {
  5. darkMode: "class",
  6. corePlugins: {
  7. preflight: false,
  8. },
  9. content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
  10. theme: {
  11. /**
  12. * @see https://tailwindcss.com/docs/customizing-colors#using-css-variables
  13. */
  14. colors: {
  15. /**
  16. * 使用 Ant Design 的颜色系统来替代 Tailwind CSS 默认的颜色配置
  17. * 说明:对于亮色和暗色模式,除基础色板外的颜色会自动适配主题,无需额外配置(例如:bg-colorBorderSecondary)
  18. * 但基础色板(如 bg-cyan-100)仍需手动设置暗色模式样式
  19. * @see https://ant.design/docs/spec/colors
  20. */
  21. ...getColorPalettes,
  22. },
  23. /**
  24. * Use ant design breakpoints
  25. * @see https://tailwindcss.com/docs/breakpoints
  26. * @see https://ant.design/components/layout-cn#breakpoint-width
  27. */
  28. screens: {
  29. "xs": "480px",
  30. "sm": "576px",
  31. "md": "768px",
  32. "lg": "992px",
  33. "xl": "1200px",
  34. "2xl": "1600px",
  35. },
  36. extend: {
  37. keyframes: {
  38. wiggle: {
  39. "0%, 100%": { "transform-origin": "top" },
  40. "15%": { transform: "rotateZ(10deg)" },
  41. "30%": { transform: "rotateZ(-10deg)" },
  42. "45%": { transform: "rotateZ(5deg)" },
  43. "60%": { transform: "rotateZ(-5deg)" },
  44. "75%": { transform: "rotateZ(2deg)" },
  45. },
  46. bounceInDownOutUp: {
  47. "0%": { transform: "translateY(0)" },
  48. "50%": { transform: "translateY(-20px)" },
  49. "100%": { transform: "translateY(0)" },
  50. },
  51. },
  52. animation: {
  53. wiggle: "wiggle 1s both",
  54. bounceInDownOutUp: "bounceInDownOutUp 4s ease-in-out 0ms infinite",
  55. },
  56. },
  57. },
  58. plugins: [
  59. plugin(({ addVariant }) => {
  60. const languages = ["en-US", "zh-CN"];
  61. /**
  62. * 添加 lang 伪类选择器
  63. *
  64. * @example
  65. * ```
  66. * en-US:text-white
  67. * ```
  68. */
  69. for (const lang of languages) {
  70. addVariant(`${lang}`, `&:lang(${lang})`);
  71. }
  72. }),
  73. ],
  74. } satisfies Config;