
Customization
A guide to configuring and customizing your Tailwind installation.
Because Tailwind is a framework for building bespoke user interfaces, it has been designed from the ground up with customization in mind.
By default, Tailwind will look for an optional tailwind.config.js file at the root of your project where you can define any customizations.
/** @type {import('tailwindcss').Config} */
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',
      }
    }
  },
}Every section of the config file is optional, so you only have to specify what you’d like to change. Any missing sections will fall back to Tailwind’s default configuration.
Generate a Tailwind config file for your project using the Tailwind CLI utility included when you install the tailwindcss npm package:
npx tailwindcss initThis will create a minimal tailwind.config.js file at the root of your project:
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [],
  theme: {
    extend: {},
  },
  plugins: [],
}To use a name other than tailwind.config.js, pass it as an argument on the command-line:
npx tailwindcss init tailwindcss-config.jsWhen you use a custom file name, you will need to specify it as a command-line argument when compiling your CSS with the Tailwind CLI tool:
npx tailwindcss -c ./tailwindcss-config.js -i input.css -o output.cssIf you’re using Tailwind as a PostCSS plugin, you will need to specify your custom configuration path in your PostCSS configuration:
module.exports = {
  plugins: {
    tailwindcss: { config: './tailwindcss-config.js' },
  },
}Alternatively, you can specify your custom configuration path using the @config directive:
@config "./tailwindcss-config.js";
@tailwind base;
@tailwind components;
@tailwind utilities;Learn more about the @config directive in the Functions & Directives documentation.
You can also configure Tailwind CSS in ESM or even TypeScript:
/** @type {import('tailwindcss').Config} */
export default {
  content: [],
  theme: {
    extend: {},
  },
  plugins: [],
}
When you run npx tailwindcss init, we’ll detect if your project is an ES Module and automatically generate your config file with the right syntax.
You can also generate an ESM config file explicitly by using the --esm flag:
npx tailwindcss init --esmTo generate a TypeScript config file, use the --ts flag:
npx tailwindcss init --tsUse the -p flag if you’d like to also generate a basic postcss.config.js file alongside your tailwind.config.js file:
npx tailwindcss init -pThis will generate a postcss.config.js file in your project that looks like this:
module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}For most users we encourage you to keep your config file as minimal as possible, and only specify the things you want to customize.
If you’d rather scaffold a complete configuration file that includes all of Tailwind’s default configuration, use the --full option:
npx tailwindcss init --fullYou’ll get a file that matches the default configuration file Tailwind uses internally.
The content section is where you configure the paths to all of your HTML templates, JS components, and any other files that contain Tailwind class names.
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    './pages/**/*.{html,js}',
    './components/**/*.{html,js}',
  ],
  // ...
}Learn more about configuring your content sources in the Content Configuration documentation.
The theme section is where you define your color palette, fonts, type scale, border sizes, breakpoints — anything related to the visual design of your site.
/** @type {import('tailwindcss').Config} */
module.exports = {
  // ...
  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',
      }
    }
  }
}Learn more about the default theme and how to customize it in the theme configuration guide.
The plugins section allows you to register plugins with Tailwind that can be used to generate extra utilities, components, base styles, or custom variants.
/** @type {import('tailwindcss').Config} */
module.exports = {
  // ...
  plugins: [
    require('@tailwindcss/forms'),
    require('@tailwindcss/aspect-ratio'),
    require('@tailwindcss/typography'),
    require('tailwindcss-children'),
  ],
}Learn more about writing your own plugins in the plugin authoring guide.
The presets section allows you to specify your own custom base configuration instead of using Tailwind’s default base configuration.
/** @type {import('tailwindcss').Config} */
module.exports = {
  // ...
  presets: [
    require('@acmecorp/base-tailwind-config')
  ],
  // Project-specific customizations
  theme: {
    //...
  },
}Learn more about presets in the presets documentation.
The prefix option allows you to add a custom prefix to all of Tailwind’s generated utility classes. This can be really useful when layering Tailwind on top of existing CSS where there might be naming conflicts.
For example, you could add a tw- prefix by setting the prefix option like so:
/** @type {import('tailwindcss').Config} */
module.exports = {
  prefix: 'tw-',
}Now every class will be generated with the configured prefix:
.tw-text-left {
  text-align: left;
}
.tw-text-center {
  text-align: center;
}
.tw-text-right {
  text-align: right;
}
/* etc. */It’s important to understand that this prefix is added after any variant modifiers. That means that classes with responsive or state modifiers like sm: or hover: will still have the responsive or state modifier first, with your custom prefix appearing after the colon:
<div class="tw-text-lg md:tw-text-xl tw-bg-red-500 hover:tw-bg-blue-500">
  <!-- -->
</div>The dash modifier for negative values should be added before your prefix, so -mt-8 would become -tw-mt-8 if you’ve configured tw- as your prefix:
<div class="-tw-mt-8">
  <!-- -->
</div>Prefixes are only added to classes generated by Tailwind; no prefix will be added to your own custom classes.
That means if you add your own custom utility like this:
@layer utilities {
  .bg-brand-gradient { /* ... */ }
}…the generated variants will not have your configured prefix:
.bg-brand-gradient { /* ... */ }
.hover\:bg-brand-gradient:hover { /* ... */ }If you’d like to prefix your own utilities as well, just add the prefix to the class definition:
@layer utilities {
  .tw-bg-brand-gradient { /* ... */ }
}The important option lets you control whether or not Tailwind’s utilities should be marked with !important. This can be really useful when using Tailwind with existing CSS that has high specificity selectors.
To generate utilities as !important, set the important key in your configuration options to true:
/** @type {import('tailwindcss').Config} */
module.exports = {
  important: true,
}Now all of Tailwind’s utility classes will be generated as !important:
.leading-none {
  line-height: 1 !important;
}
.leading-tight {
  line-height: 1.25 !important;
}
.leading-snug {
  line-height: 1.375 !important;
}
/* etc. */This also applies to any custom utilities you define in your CSS using the @layer utilities directive:
/* Input */
@layer utilities {
  .bg-brand-gradient {
    background-image: linear-gradient(#3490dc, #6574cd);
  }
}
/* Output */
.bg-brand-gradient {
  background-image: linear-gradient(#3490dc, #6574cd) !important;
}Setting important to true can introduce some issues when incorporating third-party JS libraries that add inline styles to your elements. In those cases, Tailwind’s !important utilities defeat the inline styles, which can break your intended design.
To get around this, you can set important to an ID selector like #app instead:
/** @type {import('tailwindcss').Config} */
module.exports = {
  // ...
  important: '#app',
}This configuration will prefix all of your utilities with the given selector, effectively increasing their specificity without actually making them !important.
After you specify the important selector, you’ll need to ensure that the root element of your site matches it.  Using the example above, we would need to set our root element’s id attribute to app in order for styles to work properly.
After your configuration is all set up and your root element matches the selector in your Tailwind config, all of Tailwind’s utilities will have a high enough specificity to defeat other classes used in your project, without interfering with inline styles:
<html>
<!-- ... -->
<style>
  .high-specificity .nested .selector {
    color: blue;
  }
</style>
<body id="app">
  <div class="high-specificity">
    <div class="nested">
      <!-- Will be red-500 -->
      <div class="selector text-red-500"><!-- ... --></div>
    </div>
  </div>
  <!-- Will be #bada55 -->
  <div class="text-red-500" style="color: #bada55;"><!-- ... --></div>
</body>
</html>When using the selector strategy, be sure that the template file that includes your root selector is included in your content configuration, otherwise all of your CSS will be removed when building for production.
Alternatively, you can make any utility important by adding a ! character to the beginning:
<p class="!font-medium font-bold">
  This will be medium even though bold comes later in the CSS.
</p>The ! always goes at the beginning of the utility name, after any variants, but before any prefix:
<div class="sm:hover:!tw-font-bold">This can be useful in rare situations where you need to increase specificity because you’re at war with some styles you don’t control.
The separator option lets you customize which character should be used to separate modifiers (screen sizes, hover, focus, etc.) from utility names (text-center, items-end, etc.).
We use a colon by default (:), but it can be useful to change this if you’re using a templating language like Pug that doesn’t support special characters in class names.
/** @type {import('tailwindcss').Config} */
module.exports = {
  separator: '_',
}The corePlugins section lets you completely disable classes that Tailwind would normally generate by default if you don’t need them for your project.
To disable specific core plugins, provide an object for corePlugins that sets those plugins to false:
/** @type {import('tailwindcss').Config} */
module.exports = {
  corePlugins: {
    float: false,
    objectFit: false,
    objectPosition: false,
  }
}If you’d like to safelist which core plugins should be enabled, provide an array that includes a list of the core plugins you’d like to use:
/** @type {import('tailwindcss').Config} */
module.exports = {
  corePlugins: [
    'margin',
    'padding',
    'backgroundColor',
    // ...
  ]
}If you’d like to disable all of Tailwind’s core plugins and simply use Tailwind as a tool for processing your own custom plugins, provide an empty array:
/** @type {import('tailwindcss').Config} */
module.exports = {
  corePlugins: []
}Here’s a list of every core plugin for reference:
| Core Plugin | Description | 
|---|---|
| accentColor | The accent-colorutilities likeaccent-green-800 | 
| accessibility | The sr-onlyandnot-sr-onlyutilities | 
| alignContent | The align-contentutilities likecontent-between | 
| alignItems | The align-itemsutilities likeitems-center | 
| alignSelf | The align-selfutilities likeself-end | 
| animation | The animationutilities likeanimate-ping | 
| appearance | The appearanceutilities likeappearance-none | 
| aspectRatio | The aspect-ratioutilities likeaspect-square | 
| backdropBlur | The backdrop-blurutilities likebackdrop-blur-md | 
| backdropBrightness | The backdrop-brightnessutilities likebackdrop-brightness-100 | 
| backdropContrast | The backdrop-contrastutilities likebackdrop-contrast-100 | 
| backdropFilter | The backdrop-filterutilities likebackdrop-filter | 
| backdropGrayscale | The backdrop-grayscaleutilities likebackdrop-grayscale-0 | 
| backdropHueRotate | The backdrop-hue-rotateutilities likebackdrop-hue-rotate-30 | 
| backdropInvert | The backdrop-invertutilities likebackdrop-invert-0 | 
| backdropOpacity | The backdrop-opacityutilities likebackdrop-opacity-50 | 
| backdropSaturate | The backdrop-saturateutilities likebackdrop-saturate-100 | 
| backdropSepia | The backdrop-sepiautilities likebackdrop-sepia-0 | 
| backgroundAttachment | The background-attachmentutilities likebg-local | 
| backgroundBlendMode | The background-blend-modeutilities likebg-blend-color-burn | 
| backgroundClip | The background-cliputilities likebg-clip-padding | 
| backgroundColor | The background-colorutilities likebg-green-800 | 
| backgroundImage | The background-imageutilities likebg-gradient-to-br | 
| backgroundOpacity | The background-coloropacity utilities likebg-opacity-25 | 
| backgroundOrigin | The background-originutilities likebg-origin-padding | 
| backgroundPosition | The background-positionutilities likebg-left-top | 
| backgroundRepeat | The background-repeatutilities likebg-repeat-x | 
| backgroundSize | The background-sizeutilities likebg-cover | 
| blur | The blurutilities likeblur-md | 
| borderCollapse | The border-collapseutilities likeborder-collapse | 
| borderColor | The border-colorutilities likeborder-e-green-800 | 
| borderOpacity | The border-coloropacity utilities likeborder-opacity-25 | 
| borderRadius | The border-radiusutilities likerounded-ss-lg | 
| borderSpacing | The border-spacingutilities likeborder-spacing-x-28 | 
| borderStyle | The border-styleutilities likeborder-dotted | 
| borderWidth | The border-widthutilities likeborder-e-4 | 
| boxDecorationBreak | The box-decoration-breakutilities likedecoration-clone | 
| boxShadow | The box-shadowutilities likeshadow-lg | 
| boxShadowColor | The box-shadow-colorutilities likeshadow-green-800 | 
| boxSizing | The box-sizingutilities likebox-border | 
| breakAfter | The break-afterutilities likebreak-after-avoid-page | 
| breakBefore | The break-beforeutilities likebreak-before-avoid-page | 
| breakInside | The break-insideutilities likebreak-inside-avoid | 
| brightness | The brightnessutilities likebrightness-100 | 
| captionSide | The caption-sideutilities likecaption-top | 
| caretColor | The caret-colorutilities likecaret-green-800 | 
| clear | The clearutilities likeclear-left | 
| columns | The columnsutilities likecolumns-auto | 
| contain | The containutilities likecontain-size | 
| container | The containercomponent | 
| content | The contentutilities likecontent-none | 
| contrast | The contrastutilities likecontrast-100 | 
| cursor | The cursorutilities likecursor-grab | 
| display | The displayutilities liketable-column-group | 
| divideColor | The between elements border-colorutilities likedivide-slate-500 | 
| divideOpacity | The divide-opacityutilities likedivide-opacity-50 | 
| divideStyle | The divide-styleutilities likedivide-dotted | 
| divideWidth | The between elements border-widthutilities likedivide-x-2 | 
| dropShadow | The drop-shadowutilities likedrop-shadow-lg | 
| fill | The fillutilities likefill-green-700 | 
| filter | The filterutilities likefilter | 
| flex | The flexutilities likeflex-auto | 
| flexBasis | The flex-basisutilities likebasis-px | 
| flexDirection | The flex-directionutilities likeflex-row-reverse | 
| flexGrow | The flex-growutilities likeflex-grow | 
| flexShrink | The flex-shrinkutilities likeflex-shrink | 
| flexWrap | The flex-wraputilities likeflex-wrap-reverse | 
| float | The floatutilities likefloat-right | 
| fontFamily | The font-familyutilities likefont-serif | 
| fontSize | The font-sizeutilities liketext-3xl | 
| fontSmoothing | The font-smoothingutilities likeantialiased | 
| fontStyle | The font-styleutilities likeitalic | 
| fontVariantNumeric | The font-variant-numericutilities likeoldstyle-nums | 
| fontWeight | The font-weightutilities likefont-medium | 
| forcedColorAdjust | The forced-color-adjustutilities likeforced-color-adjust-auto | 
| gap | The gaputilities likegap-x-28 | 
| gradientColorStops | The gradient-color-stopsutilities likevia-emerald-700 | 
| grayscale | The grayscaleutilities likegrayscale-0 | 
| gridAutoColumns | The grid-auto-columnsutilities likeauto-cols-min | 
| gridAutoFlow | The grid-auto-flowutilities likegrid-flow-dense | 
| gridAutoRows | The grid-auto-rowsutilities likeauto-rows-min | 
| gridColumn | The grid-columnutilities likecol-span-6 | 
| gridColumnEnd | The grid-column-endutilities likecol-end-7 | 
| gridColumnStart | The grid-column-startutilities likecol-start-7 | 
| gridRow | The grid-rowutilities likerow-span-6 | 
| gridRowEnd | The grid-row-endutilities likerow-end-7 | 
| gridRowStart | The grid-row-startutilities likerow-start-7 | 
| gridTemplateColumns | The grid-template-columnsutilities likegrid-cols-7 | 
| gridTemplateRows | The grid-template-rowsutilities likegrid-rows-7 | 
| height | The heightutilities likeh-96 | 
| hueRotate | The hue-rotateutilities likehue-rotate-30 | 
| hyphens | The hyphensutilities likehyphens-manual | 
| inset | The insetutilities likeend-44 | 
| invert | The invertutilities likeinvert-0 | 
| isolation | The isolationutilities likeisolate | 
| justifyContent | The justify-contentutilities likejustify-center | 
| justifyItems | The justify-itemsutilities likejustify-items-end | 
| justifySelf | The justify-selfutilities likejustify-self-end | 
| letterSpacing | The letter-spacingutilities liketracking-normal | 
| lineClamp | The line-clamputilities likeline-clamp-4 | 
| lineHeight | The line-heightutilities likeleading-9 | 
| listStyleImage | The list-style-imageutilities likelist-image-none | 
| listStylePosition | The list-style-positionutilities likelist-inside | 
| listStyleType | The list-style-typeutilities likelist-disc | 
| margin | The marginutilities likeme-28 | 
| maxHeight | The max-heightutilities likemax-h-44 | 
| maxWidth | The max-widthutilities likemax-w-80 | 
| minHeight | The min-heightutilities likemin-h-44 | 
| minWidth | The min-widthutilities likemin-w-36 | 
| mixBlendMode | The mix-blend-modeutilities likemix-blend-hard-light | 
| objectFit | The object-fitutilities likeobject-fill | 
| objectPosition | The object-positionutilities likeobject-left-top | 
| opacity | The opacityutilities likeopacity-50 | 
| order | The orderutilities likeorder-8 | 
| outlineColor | The outline-colorutilities likeoutline-green-800 | 
| outlineOffset | The outline-offsetutilities likeoutline-offset-2 | 
| outlineStyle | The outline-styleutilities likeoutline-dashed | 
| outlineWidth | The outline-widthutilities likeoutline-2 | 
| overflow | The overflowutilities likeoverflow-x-hidden | 
| overscrollBehavior | The overscroll-behaviorutilities likeoverscroll-y-contain | 
| padding | The paddingutilities likepe-28 | 
| placeContent | The place-contentutilities likeplace-content-between | 
| placeItems | The place-itemsutilities likeplace-items-center | 
| placeSelf | The place-selfutilities likeplace-self-end | 
| placeholderColor | The placeholder colorutilities likeplaceholder-red-600 | 
| placeholderOpacity | The placeholder coloropacity utilities likeplaceholder-opacity-25 | 
| pointerEvents | The pointer-eventsutilities likepointer-events-none | 
| position | The positionutilities likeabsolute | 
| preflight | Tailwind's base/reset styles | 
| resize | The resizeutilities likeresize-y | 
| ringColor | The ring-colorutilities likering-green-800 | 
| ringOffsetColor | The ring-offset-colorutilities likering-offset-green-800 | 
| ringOffsetWidth | The ring-offset-widthutilities likering-offset-2 | 
| ringOpacity | The ring-opacityutilities likering-opacity-50 | 
| ringWidth | The ring-widthutilities likering-4 | 
| rotate | The rotateutilities likerotate-6 | 
| saturate | The saturateutilities likesaturate-100 | 
| scale | The scaleutilities likescale-x-95 | 
| scrollBehavior | The scroll-behaviorutilities likescroll-auto | 
| scrollMargin | The scroll-marginutilities likescroll-me-28 | 
| scrollPadding | The scroll-paddingutilities likescroll-pe-28 | 
| scrollSnapAlign | The scroll-snap-alignutilities likesnap-end | 
| scrollSnapStop | The scroll-snap-stoputilities likesnap-normal | 
| scrollSnapType | The scroll-snap-typeutilities likesnap-y | 
| sepia | The sepiautilities likesepia-0 | 
| size | The sizeutilities likesize-0.5 | 
| skew | The skewutilities likeskew-x-12 | 
| space | The "space-between" utilities like space-x-4 | 
| stroke | The strokeutilities likestroke-green-700 | 
| strokeWidth | The stroke-widthutilities likestroke-1 | 
| tableLayout | The table-layoututilities liketable-auto | 
| textAlign | The text-alignutilities liketext-right | 
| textColor | The text-colorutilities liketext-green-800 | 
| textDecoration | The text-decorationutilities likeoverline | 
| textDecorationColor | The text-decoration-colorutilities likedecoration-green-800 | 
| textDecorationStyle | The text-decoration-styleutilities likedecoration-dotted | 
| textDecorationThickness | The text-decoration-thicknessutilities likedecoration-4 | 
| textIndent | The text-indentutilities likeindent-28 | 
| textOpacity | The text-opacityutilities liketext-opacity-50 | 
| textOverflow | The text-overflowutilities likeoverflow-ellipsis | 
| textTransform | The text-transformutilities likelowercase | 
| textUnderlineOffset | The text-underline-offsetutilities likeunderline-offset-2 | 
| textWrap | The text-wraputilities liketext-nowrap | 
| touchAction | The touch-actionutilities liketouch-pan-right | 
| transform | The transformutility (for enabling transform features) | 
| transformOrigin | The transform-originutilities likeorigin-bottom-right | 
| transitionDelay | The transition-delayutilities likedelay-200 | 
| transitionDuration | The transition-durationutilities likeduration-200 | 
| transitionProperty | The transition-propertyutilities liketransition-colors | 
| transitionTimingFunction | The transition-timing-functionutilities likeease-in | 
| translate | The translateutilities liketranslate-x-full | 
| userSelect | The user-selectutilities likeselect-text | 
| verticalAlign | The vertical-alignutilities likealign-bottom | 
| visibility | The visibilityutilities likeinvisible | 
| whitespace | The whitespaceutilities likewhitespace-pre | 
| width | The widthutilities likew-2.5 | 
| willChange | The will-changeutilities likewill-change-scroll | 
| wordBreak | The word-breakutilities likebreak-words | 
| zIndex | The z-indexutilities likez-30 | 
For projects that need to generate multiple CSS files using different Tailwind configurations, use the @config directive to specify which config file should be used for each CSS entry point:
@config "./tailwind.site.config.js";
@tailwind base;
@tailwind components;
@tailwind utilities;Learn more about the @config directive in the Functions & Directives documentation.
It can often be useful to reference your configuration values in your own client-side JavaScript — for example to access some of your theme values when dynamically applying inline styles in a React or Vue component.
To make this easy, Tailwind provides a resolveConfig helper you can use to generate a fully merged version of your configuration object:
import resolveConfig from 'tailwindcss/resolveConfig'
import tailwindConfig from './tailwind.config.js'
const fullConfig = resolveConfig(tailwindConfig)
fullConfig.theme.width[4]
// => '1rem'
fullConfig.theme.screens.md
// => '768px'
fullConfig.theme.boxShadow['2xl']
// => '0 25px 50px -12px rgba(0, 0, 0, 0.25)'Note that this will transitively pull in a lot of our build-time dependencies, resulting in bigger client-side bundle size. To avoid this, we recommend using a tool like babel-plugin-preval to generate a static version of your configuration at build-time.
We ship first-party TypeScript types for the tailwind.config.js file which give you all sorts of useful IDE support, and makes it a lot easier to make changes to your configuration without referencing the documentation quite as much.
Configuration files generated with Tailwind CLI include the necessary type annotation by default, but to configure TypeScript types manually, just add the type annotation above your configuration object:
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    // ...
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}