Vì Tailwind là một khuôn khổ để xây dựng giao diện người dùng riêng nên nó đã được thiết kế từ đầu có tính đến khả năng tùy chỉnh Theo mặc định, Tailwind sẽ tìm tệp npx tailwindcss init 9 tùy chọn ở gốc dự án của bạn, nơi bạn có thể xác định bất kỳ tùy chỉnh nàomodule.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
}
Mỗi phần của tệp cấu hình là tùy chọn, vì vậy bạn chỉ phải chỉ định những gì bạn muốn thay đổi. Mọi phần bị thiếu sẽ trở về cấu hình mặc định của Tailwind
Tạo tập tin cấu hình của bạnTạo tệp cấu hình Tailwind cho dự án của bạn bằng tiện ích Tailwind CLI đi kèm khi bạn cài đặt gói module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 0 npmnpx tailwindcss init
Điều này sẽ tạo một tệp npx tailwindcss init 9 tối thiểu ở thư mục gốc của dự án của bạnmodule.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
}
Sử dụng một tên tập tin khácĐể sử dụng một tên khác với tên npx tailwindcss init 9, hãy chuyển nó làm đối số trên dòng lệnhnpx tailwindcss init tailwindcss-config.js
Khi sử dụng tên tệp tùy chỉnh, bạn sẽ cần chỉ định tên đó làm đối số dòng lệnh khi biên dịch CSS bằng công cụ Tailwind CLI ________số 8Nếu đang sử dụng Tailwind làm plugin PostCSS, bạn sẽ cần chỉ định đường dẫn cấu hình tùy chỉnh trong cấu hình PostCSS của mình module.exports = {
plugins: {
tailwindcss: { config: './tailwindcss-config.js' },
},
}
Ngoài ra, bạn có thể chỉ định đường dẫn cấu hình tùy chỉnh của mình bằng cách sử dụng chỉ thị module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 3module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 1Tìm hiểu thêm về chỉ thị module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 3 trong tài liệu Chức năng & Chỉ thịTạo tệp cấu hình PostCSSSử dụng cờ module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 5 nếu bạn cũng muốn tạo tệp module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 6 cơ bản cùng với tệp npx tailwindcss init 9 của mìnhmodule.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 6Điều này sẽ tạo ra một tệp module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 6 trong dự án của bạn trông như thế nàymodule.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 8Giàn giáo toàn bộ cấu hình mặc địnhĐối với hầu hết người dùng, chúng tôi khuyến khích bạn giữ tệp cấu hình của mình ở mức tối thiểu nhất có thể và chỉ chỉ định những thứ bạn muốn tùy chỉnh Nếu bạn muốn tạo một tệp cấu hình hoàn chỉnh bao gồm tất cả cấu hình mặc định của Tailwind, hãy sử dụng tùy chọn module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 9module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 0Bạn sẽ nhận được một tệp khớp với tệp cấu hình mặc định mà Tailwind sử dụng nội bộ
Tùy chọn cấu hìnhnội dungPhần npx tailwindcss init tailwindcss-config.js 0 là nơi bạn định cấu hình đường dẫn đến tất cả các mẫu HTML, thành phần JS và bất kỳ tệp nào khác có chứa tên lớp TailwindTìm hiểu thêm về cách định cấu hình nguồn nội dung của bạn trong tài liệu Cấu hình nội dung chủ đềPhần npx tailwindcss init tailwindcss-config.js 1 là nơi bạn xác định bảng màu, phông chữ, tỷ lệ loại, kích thước đường viền, điểm ngắt — bất kỳ thứ gì liên quan đến thiết kế trực quan của trang web của bạnTìm hiểu thêm về chủ đề mặc định và cách tùy chỉnh chủ đề đó trong hướng dẫn cấu hình chủ đề pluginPhần npx tailwindcss init tailwindcss-config.js 2 cho phép bạn đăng ký các phần bổ trợ với Tailwind. Phần bổ trợ này có thể dùng để tạo các tiện ích, thành phần, kiểu cơ sở hoặc biến thể tùy chỉnh bổ sungTìm hiểu thêm về cách viết plugin của riêng bạn trong hướng dẫn tác giả plugin cài đặt trướcPhần npx tailwindcss init tailwindcss-config.js 3 cho phép bạn chỉ định cấu hình cơ sở tùy chỉnh của riêng mình thay vì sử dụng cấu hình cơ sở mặc định của TailwindTìm hiểu thêm về cài đặt trước trong tài liệu cài đặt trước tiền tốTùy chọn npx tailwindcss init tailwindcss-config.js 4 cho phép bạn thêm tiền tố tùy chỉnh vào tất cả các lớp tiện ích do Tailwind tạo. Điều này có thể thực sự hữu ích khi xếp lớp Tailwind lên trên CSS hiện có, nơi có thể xảy ra xung đột về đặt tênVí dụ: bạn có thể thêm tiền tố npx tailwindcss init tailwindcss-config.js 5 bằng cách đặt tùy chọn npx tailwindcss init tailwindcss-config.js 4 như vậynpx tailwindcss init 0Bây giờ mọi lớp sẽ được tạo với tiền tố được định cấu hình Điều quan trọng là phải hiểu rằng tiền tố này được thêm vào sau bất kỳ công cụ sửa đổi biến thể nào. Điều đó có nghĩa là các lớp có công cụ sửa đổi trạng thái hoặc phản hồi như npx tailwindcss init tailwindcss-config.js 7 hoặc npx tailwindcss init tailwindcss-config.js 8 sẽ vẫn có công cụ sửa đổi trạng thái hoặc phản hồi trước, với tiền tố tùy chỉnh của bạn xuất hiện sau dấu hai chấmCông cụ sửa đổi dấu gạch ngang cho các giá trị âm phải được thêm vào trước tiền tố của bạn, vì vậy, npx tailwindcss init tailwindcss-config.js 9 sẽ trở thành npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 0 nếu bạn đã định cấu hình npx tailwindcss init tailwindcss-config.js 5 làm tiền tố của mìnhTiền tố chỉ được thêm vào các lớp do Tailwind tạo; Điều đó có nghĩa là nếu bạn thêm tiện ích tùy chỉnh của riêng mình như thế này …các biến thể đã tạo sẽ không có tiền tố đã định cấu hình của bạn Nếu bạn cũng muốn đặt tiền tố cho các tiện ích của riêng mình, chỉ cần thêm tiền tố vào định nghĩa lớp quan trọngTùy chọn npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 2 cho phép bạn kiểm soát việc có nên đánh dấu các tiện ích của Tailwind bằng npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 3 hay không. Điều này có thể thực sự hữu ích khi sử dụng Tailwind với CSS hiện có có bộ chọn độ đặc hiệu caoĐể tạo các tiện ích dưới dạng npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 3, hãy đặt khóa npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 2 trong các tùy chọn cấu hình của bạn thành npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 6npx tailwindcss init 1Giờ đây, tất cả các lớp tiện ích của Tailwind sẽ được tạo dưới dạng npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 3Điều này cũng áp dụng cho mọi tiện ích tùy chỉnh mà bạn xác định trong CSS của mình bằng cách sử dụng chỉ thị npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 8Chiến lược lựa chọnĐặt npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 2 thành npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 6 có thể gây ra một số vấn đề khi kết hợp các thư viện JS của bên thứ ba để thêm các kiểu nội tuyến vào các phần tử của bạn. Trong những trường hợp đó, các tiện ích npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 3 của Tailwind đánh bại các kiểu nội tuyến, có thể phá vỡ thiết kế dự định của bạnĐể giải quyết vấn đề này, thay vào đó, bạn có thể đặt npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 2 thành bộ chọn ID như module.exports = {
plugins: {
tailwindcss: { config: './tailwindcss-config.js' },
},
} 3Cấu hình này sẽ thêm tiền tố vào tất cả các tiện ích của bạn với bộ chọn đã cho, tăng tính đặc hiệu của chúng một cách hiệu quả mà không thực sự biến chúng thành npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 3Sau khi bạn chỉ định bộ chọn npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.css 2, bạn sẽ cần đảm bảo rằng phần tử gốc của trang web của bạn khớp với bộ chọn đó. Sử dụng ví dụ trên, chúng ta cần đặt thuộc tính module.exports = {
plugins: {
tailwindcss: { config: './tailwindcss-config.js' },
},
} 6 của phần tử gốc thành module.exports = {
plugins: {
tailwindcss: { config: './tailwindcss-config.js' },
},
} 7 để các kiểu hoạt động bình thườngSau khi cấu hình của bạn được thiết lập xong và phần tử gốc khớp với bộ chọn trong cấu hình Tailwind của bạn, tất cả các tiện ích của Tailwind sẽ có độ đặc hiệu đủ cao để đánh bại các lớp khác được sử dụng trong dự án của bạn mà không can thiệp vào các kiểu nội tuyến Khi sử dụng chiến lược bộ chọn, hãy đảm bảo rằng tệp mẫu bao gồm bộ chọn gốc của bạn được đưa vào cấu hình nội dung của bạn, nếu không, tất cả CSS của bạn sẽ bị xóa khi xây dựng cho sản xuất Công cụ sửa đổi quan trọngNgoài ra, bạn có thể làm cho bất kỳ tiện ích nào trở nên quan trọng bằng cách thêm ký tự module.exports = {
plugins: {
tailwindcss: { config: './tailwindcss-config.js' },
},
} 8 vào đầunpx tailwindcss init 2module.exports = {
plugins: {
tailwindcss: { config: './tailwindcss-config.js' },
},
} 8 luôn ở đầu tên tiện ích, sau bất kỳ biến thể nào, nhưng trước bất kỳ tiền tố nàonpx tailwindcss init 3Điều này có thể hữu ích trong những tình huống hiếm gặp khi bạn cần tăng tính cụ thể vì bạn đang phải đối mặt với một số phong cách mà bạn không kiểm soát được phân cáchTùy chọn module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 10 cho phép bạn tùy chỉnh ký tự nào sẽ được sử dụng để phân tách các công cụ sửa đổi (kích thước màn hình, module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 11, module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 12, v.v. ) từ tên tiện ích (module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 13, module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 14, v.v. )Chúng tôi sử dụng dấu hai chấm theo mặc định ( module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 15), nhưng có thể hữu ích khi thay đổi điều này nếu bạn đang sử dụng ngôn ngữ tạo khuôn mẫu như Pug không hỗ trợ các ký tự đặc biệt trong tên lớpnpx tailwindcss init 4Plugin cốt lõiPhần module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 16 cho phép bạn tắt hoàn toàn các lớp mà Tailwind thường tạo theo mặc định nếu bạn không cần chúng cho dự án của mìnhĐể tắt các plugin cốt lõi cụ thể, hãy cung cấp một đối tượng cho module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 16 để đặt các plugin đó thành module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 18npx tailwindcss init 5Nếu bạn muốn đưa vào danh sách an toàn những plugin cốt lõi nào sẽ được bật, hãy cung cấp một mảng bao gồm danh sách các plugin cốt lõi mà bạn muốn sử dụng Nếu bạn muốn tắt tất cả plugin cốt lõi của Tailwind và chỉ cần sử dụng Tailwind làm công cụ để xử lý plugin tùy chỉnh của riêng mình, hãy cung cấp một mảng trống npx tailwindcss init 6Đây là danh sách mọi plugin cốt lõi để tham khảo Core PluginDescription module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 19The module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 60 utilities like module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 61module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 62The module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 63 and module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 64 utilitiesmodule.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 65The module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 66 utilities like module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 67module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 68The module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 69 utilities like module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 80module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 81The module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 82 utilities like module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 83module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 84The module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 84 utilities like module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 86module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 87The module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 87 utilities like module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
} 89module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 00The module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 01 utilities like module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 02module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 03The module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 04 utilities like module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 05module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 06The module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 07 utilities like module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 08module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 09The npx tailwindcss init 00 utilities like npx tailwindcss init 01npx tailwindcss init 02The npx tailwindcss init 03 utilities like npx tailwindcss init 03npx tailwindcss init 05The
Sử dụng nhiều cấu hìnhĐối với các dự án cần tạo nhiều tệp CSS bằng cách sử dụng các cấu hình Tailwind khác nhau, hãy sử dụng lệnh module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 3 để chỉ định tệp cấu hình nào sẽ được sử dụng cho từng điểm nhập CSSnpx tailwindcss init 7npx tailwindcss init 8Tìm hiểu thêm về chỉ thị module.exports = {
content: [],
theme: {
extend: {},
},
plugins: [],
} 3 trong tài liệu Chức năng & Chỉ thị
Tham chiếu trong JavaScriptThường có thể hữu ích khi tham chiếu các giá trị cấu hình của bạn trong JavaScript phía máy khách của riêng bạn — ví dụ: để truy cập một số giá trị chủ đề của bạn khi áp dụng động các kiểu nội tuyến trong thành phần React hoặc Vue Để làm cho việc này trở nên dễ dàng, Tailwind cung cấp một trình trợ giúp module.exports = {
plugins: {
tailwindcss: { config: './tailwindcss-config.js' },
},
} 79 mà bạn có thể sử dụng để tạo phiên bản được hợp nhất hoàn toàn cho đối tượng cấu hình của mìnhLưu ý rằng điều này sẽ kéo theo nhiều phụ thuộc thời gian xây dựng của chúng tôi, dẫn đến kích thước gói phía máy khách lớn hơn. Để tránh điều này, chúng tôi khuyên bạn nên sử dụng một công cụ như babel-plugin-preval để tạo phiên bản tĩnh cho cấu hình của bạn tại thời điểm xây dựng
Các loại TypeScriptChúng tôi cung cấp các loại TypeScript của bên thứ nhất cho tệp npx tailwindcss init 9, cung cấp cho bạn tất cả các loại hỗ trợ IDE hữu ích và giúp bạn thực hiện các thay đổi đối với cấu hình của mình dễ dàng hơn rất nhiều mà không cần tham khảo nhiều tài liệuCác tệp cấu hình được tạo bằng Tailwind CLI bao gồm chú thích loại cần thiết theo mặc định, nhưng để định cấu hình các loại TypeScript theo cách thủ công, chỉ cần thêm chú thích loại phía trên đối tượng cấu hình của bạn |