Tailwind plugins are JavaScript functions that add new CSS utilities or components by injecting CSS rules during the build step. They do not modify HTML or replace core styles.
const plugin = require('tailwindcss/plugin'); module.exports = { plugins: [ /* Your plugin here */ ] }
The plugin function takes a callback with an object parameter. The addComponents method is called with an object defining the new CSS classes.
const plugin = require('tailwindcss/plugin'); module.exports = { plugins: [ plugin(function({ addComponents }) { addComponents({ '.card': { padding: '2rem', borderRadius: '0.5rem', boxShadow: '0 4px 6px rgba(0,0,0,0.1)' } }) }) ] }
The plugin adds a '.card' class with padding 2rem, border-radius 0.5rem, and the specified box-shadow exactly as coded.
The plugin adds a CSS class selector '.alert-warning' exactly as specified, with a dot prefix and hyphen in the name.
Accessible modals must trap keyboard focus inside and show visible focus styles (like focus-visible) so keyboard users can navigate easily.
