0Pricing
Tailwind CSS Academy · Lektion

Plugins hinzufügen und konfigurieren

Aktivieren Sie offizielle Tailwind-Plugins wie @tailwindcss/typography und @tailwindcss/forms und konfigurieren Sie sie in tailwind.config.js.

Plugins hinzufügen und konfigurieren ist eine kostenlose Tailwind CSS Academy-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Tailwind CSS Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Tailwind CSS Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

What Tailwind Plugins Do

Tailwind plugins extend the generated CSS by adding new utility classes, component classes, base styles, or variant modifiers. Unlike modifying the config's theme section (which only changes design token values), plugins can add entirely new CSS rules, selectors, and even new class families. Official plugins from the Tailwind team cover common needs like typography and forms, while the community provides hundreds more.

The Official Tailwind Plugin Ecosystem

The Tailwind team maintains four first-party plugins, each solving a specific problem that falls outside the core utility classes. @tailwindcss/typography styles rich HTML content from markdown. @tailwindcss/forms resets browser form styles for easier customization. @tailwindcss/aspect-ratio adds aspect ratio utilities for older browsers. @tailwindcss/container-queries adds container query support as utility classes.

# Install official Tailwind plugins
npm install @tailwindcss/typography
npm install @tailwindcss/forms
npm install @tailwindcss/aspect-ratio
npm install @tailwindcss/container-queries

Adding Plugins to the Config

Plugins are registered in the plugins array of tailwind.config.js. Simply require() the plugin and add it to the array. Plugins without configuration options are added directly. Plugins that accept options are called as functions with a configuration object. Multiple plugins can coexist in the same array without conflict.

// tailwind.config.js
module.exports = {
  content: ['./src/**/*.{html,js}'],
  theme: { extend: {} },
  plugins: [
    require('@tailwindcss/typography'),
    require('@tailwindcss/forms'),
    require('@tailwindcss/aspect-ratio'),
    require('@tailwindcss/container-queries'),
  ],
};

Using @tailwindcss/typography

The @tailwindcss/typography plugin adds a prose class (and its variants) that applies beautiful typographic styles to raw HTML content — like rendered markdown from a CMS or blog. Apply prose to a container and all its descendant elements (headings, paragraphs, lists, code blocks, blockquotes) get styled automatically without adding classes to each individual element.

<!-- Enable prose styling on a container -->
<article class="prose prose-lg dark:prose-invert max-w-none">
  <h1>My Blog Post</h1>
  <p>This paragraph is automatically styled with readable typography.</p>
  <ul>
    <li>List items look great too</li>
    <li>No extra classes needed</li>
  </ul>
  <pre><code>code blocks are styled</code></pre>
</article>

Configuring @tailwindcss/typography

The typography plugin is configurable both through the plugin options and through the Tailwind theme. Use strategy: 'class' to only apply prose styles when the prose class is explicitly added (as opposed to base styles). Customize the prose scale (sm, base, lg, xl, 2xl) and override specific element styles through the theme.typography key in your config.

// tailwind.config.js
module.exports = {
  plugins: [
    require('@tailwindcss/typography')({
      // No extra options needed for most uses
    }),
  ],
  theme: {
    extend: {
      typography: (theme) => ({
        DEFAULT: {
          css: {
            color: theme('colors.gray.700'),
            'h1, h2, h3': { color: theme('colors.gray.900') },
            a: { color: theme('colors.blue.600') },
          },
        },
      }),
    },
  },
};

Using @tailwindcss/forms

The @tailwindcss/forms plugin resets the default browser styles for form elements like inputs, selects, textareas, checkboxes, and radio buttons. Without it, different browsers render these controls completely differently. With it, all form elements get a consistent, minimal baseline style that Tailwind utilities can then enhance. Choose strategy: 'class' to opt into the resets per element rather than globally.

// tailwind.config.js
module.exports = {
  plugins: [
    require('@tailwindcss/forms')({
      strategy: 'class', // opt-in: use class='form-input' etc
      // strategy: 'base' (default) — applies to all form elements
    }),
  ],
};

<!-- With class strategy, add the form-* class -->
<input type="text" class="form-input rounded-lg border-gray-300 w-full" />
<select class="form-select rounded-lg" />
<input type="checkbox" class="form-checkbox text-blue-600" />

Using @tailwindcss/container-queries

CSS container queries let components respond to the size of their parent container rather than the viewport. The @tailwindcss/container-queries plugin adds @container marking and @sm:, @md:, @lg: responsive prefixes that work like breakpoints but relative to the nearest container. This is powerful for building truly reusable components that adapt to any context they are placed in.

<div class="@container">
  <div class="flex flex-col @md:flex-row gap-4">
    <div class="@md:w-1/3">
      <!-- Sidebar inside the container -->
    </div>
    <div class="@md:flex-1">
      <!-- Content area -->
    </div>
  </div>
</div>

Community Plugins

Beyond official plugins, a rich ecosystem of community plugins extends Tailwind with animation libraries, scrollbar utilities, grid patterns, and more. Popular examples include tailwindcss-animate for CSS animations (used by shadcn/ui), tailwind-scrollbar for scrollbar styling, and @headlessui/tailwindcss for Headless UI state variants. Research plugins before adding them — check download counts, maintenance status, and bundle impact.

// tailwind.config.js
module.exports = {
  plugins: [
    require('tailwindcss-animate'),
    require('tailwind-scrollbar'),
  ],
};

<!-- Use animation plugin classes -->
<div class="animate-in fade-in slide-in-from-bottom-4 duration-300">
  Animated content
</div>

Writing an Inline Plugin

You can write a custom plugin inline inside the plugins array using Tailwind's plugin function from the tailwindcss/plugin module. This is useful for adding a small set of custom utilities or components without creating a separate file. The plugin function receives a helper object with addUtilities, addComponents, addBase, and addVariant methods.

const plugin = require('tailwindcss/plugin');

module.exports = {
  plugins: [
    plugin(function({ addUtilities }) {
      addUtilities({
        '.text-shadow-sm': { 'text-shadow': '0 1px 2px rgba(0,0,0,0.1)' },
        '.text-shadow': { 'text-shadow': '0 2px 4px rgba(0,0,0,0.2)' },
        '.text-shadow-lg': { 'text-shadow': '0 4px 8px rgba(0,0,0,0.3)' },
        '.text-shadow-none': { 'text-shadow': 'none' },
      });
    }),
  ],
};

Plugin Ordering and Conflicts

Plugins are applied in the order they appear in the array. If two plugins add utilities with the same class name, the later plugin wins. Be aware that plugins using addBase inject styles into Tailwind's base layer, which may interact with existing reset styles. Test for conflicts after adding multiple plugins by inspecting the compiled CSS for unexpected overrides or duplicate declarations.

// Order matters when plugins could conflict
module.exports = {
  plugins: [
    require('@tailwindcss/forms'),      // runs first
    require('./plugins/my-forms'),       // can override forms plugin if needed
    require('@tailwindcss/typography'), // independent, no conflict
  ],
};

Verifying Plugin Installation

After adding a plugin, verify it is working by checking that its classes appear in your compiled CSS and apply correctly in the browser. For the typography plugin, add the prose class to a content element and inspect the applied styles. For forms, check that input elements have the normalized baseline appearance. If classes from the plugin are absent, ensure the plugin is listed in the correct plugins array and the package is installed.

# Verify plugin is installed
npm list @tailwindcss/typography

# Check if prose class appears in built CSS
npx tailwindcss build | grep '.prose'

# Or build to a file and search
npx tailwindcss -i ./input.css -o ./out.css && grep '.prose' out.css | head -5

Quick Check

Test your understanding of adding and configuring Tailwind plugins.

Lesson Recap

In this lesson you learned: Tailwind plugins are registered in the plugins array of the config, the four official plugins cover typography, forms, aspect ratio, and container queries, and you can write inline plugins using the plugin() helper for custom utilities. Next up we explore adding custom colors, fonts, and spacing to your Tailwind project.

Häufig gestellte Fragen

Ist die Lektion „Plugins hinzufügen und konfigurieren“ kostenlos?

Ja — der vollständige Text von „Plugins hinzufügen und konfigurieren“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Tailwind CSS Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Tailwind CSS Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Plugins hinzufügen und konfigurieren“?

Aktivieren Sie offizielle Tailwind-Plugins wie @tailwindcss/typography und @tailwindcss/forms und konfigurieren Sie sie in tailwind.config.js. Du übst Tailwind CSS Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Tailwind CSS Academy zu starten?

Keine Vorkenntnisse erforderlich. Tailwind CSS Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Plugins hinzufügen und konfigurieren“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Tailwind CSS Academy-Lektion Code schreiben und ausführen?

Ja. Jede Tailwind CSS Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Aufbau von tailwind.config.js
  2. Content-Pfade und Bereinigung
  3. Theme erweitern oder überschreiben
  4. Plugins hinzufügen und konfigurieren
← Zurück zu Tailwind CSS Academy