tailwind.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /** @type {import('tailwindcss').Config} */
  2. module.exports = {
  3. content: [
  4. // Tailwind 会扫描这些文件,找出所有使用的工具类(如 bg-blue-500)
  5. // 只生成用到的样式,未使用的不会打包(Tree-shaking)
  6. "./public/index.html",
  7. "./src/**/*.{vue,js,ts,jsx,tsx}",
  8. ],
  9. // 这些类名强制保留,即使扫描时没发现使用
  10. // 用于动态类名(如 :class="getButtonClass(color)")
  11. // 使用原因:因为类名是动态拼接的,Tailwind 扫描时可能识别不出来,所以需要在 safelist 中手动声明。
  12. safelist: [
  13. // 统计卡片颜色
  14. 'border-blue-500',
  15. 'border-green-500',
  16. 'border-yellow-500',
  17. 'border-purple-500',
  18. 'bg-blue-100',
  19. 'bg-green-100',
  20. 'bg-yellow-100',
  21. 'bg-purple-100',
  22. 'text-blue-500',
  23. 'text-green-500',
  24. 'text-yellow-500',
  25. 'text-purple-500',
  26. 'text-red-500',
  27. // 底部按钮颜色
  28. 'bg-blue-500',
  29. 'bg-green-500',
  30. 'bg-yellow-500',
  31. 'bg-red-500',
  32. 'hover:bg-blue-600',
  33. 'hover:bg-green-600',
  34. 'hover:bg-yellow-600',
  35. 'hover:bg-red-600',
  36. ],
  37. // theme(主题扩展)
  38. // 自定义颜色和圆角大小
  39. // 可以使用 bg-primary、rounded-button 等自定义类名
  40. theme: {
  41. extend: {
  42. colors: {
  43. primary: '#3b82f6',
  44. secondary: '#60a5fa'
  45. },
  46. borderRadius: {
  47. 'none': '0px',
  48. 'sm': '2px',
  49. DEFAULT: '4px',
  50. 'md': '8px',
  51. 'lg': '12px',
  52. 'xl': '16px',
  53. '2xl': '20px',
  54. '3xl': '24px',
  55. 'full': '9999px',
  56. 'button': '4px'
  57. }
  58. },
  59. },
  60. plugins: [],
  61. }