Tailwind CSS Documentation Website
repository·main·Indexed 13 days ago
https://github.com/tailwindlabs/tailwindcss.comSource code for the official Tailwind CSS documentation website, built with Next.js. Includes guidelines on trademark usage, brand asset downloads, and technical guides for Headless UI components, Heroicons v2.0, and Tailwind Play.
What's inside tailwindcss.com
- Headless UI v1.0 provides fully accessible, framework-agnostic components for React and Vue. The library focuses on providing robust, unstyled components that handle complex interactions like focus management, nested modals, and keyboard navigation. It supports patterns like Menu, Listbox, Switch, Disclosure, Dialog, Popover, and Radio Group, ensuring they work correctly even in complex nested scenarios (e.g., a dropdown inside a modal). The API is stable and committed to long-term support.
Install and use the Studio agency template
mainStudio is a beautiful agency website template built with Next.js, MDX, and Tailwind CSS. It uses the Next.js App Router and is designed for agencies that focus on engineering or non-design work. The template includes pre-built animations, a case study workflow, and a blog workflow. It is available as a one-time purchase via the Tailwind UI all-access license.
# Studio is a paid template available at: # https://tailwindui.com/templates/studio # Purchase via Tailwind UI all-access licenseUnderstand what Preflight does
mainPreflight is an opinionated set of base styles built on top of modern-normalize that smooths over cross-browser inconsistencies. When you importtailwindcss, Preflight is automatically injected into thebaselayer. It resets margins, border styles, headings, and lists to ensure consistent behavior across browsers and prevents accidental reliance on user-agent styles.Understand the Headless UI philosophy and design goals
mainHeadless UI is a set of completely unstyled, fully accessible UI components designed to work seamlessly with Tailwind CSS. Its core philosophy is to separate behavior from design: it provides the complex logic for keyboard navigation, focus management, and accessibility, while leaving all markup and styling entirely to the user via Tailwind utility classes. This ensures that Tailwind UI examples remain easy to customize and adapt without being locked into a specific design system.Hide outlines for accessibility with outline-hidden
mainUse the
outline-hiddenutility to hide the default browser outline on focused elements while preserving the outline in forced colors mode (e.g., for high contrast users). This is the recommended approach for custom focus styling to maintain accessibility.When using
outline-hidden, it is highly recommended to apply your own focus styling (e.g., usingfocus:ringorfocus:outline-*) to ensure the element remains visibly focused.<input type="text" placeholder="Your full name" class="focus:outline-hidden focus:ring-2 focus:ring-indigo-500" /> <!-- Or using outline utilities --> <input type="text" placeholder="Your full name" class="focus:outline-hidden focus:outline-2 focus:outline-indigo-500" />Upgrade to Tailwind CSS v3.3
mainUpgrade your project to Tailwind CSS v3.3 by installing the latest version from npm. This release includes an extended color palette with 950 shades, ESM and TypeScript configuration support, logical properties for RTL layouts, and new utilities for line-clamp, gradients, and more.
To upgrade, run the following command:
npm install -D tailwindcss@latestYou can also try out the new features immediately in your browser using Tailwind Play.
Use dynamic utility values without configuration
mainTailwind CSS v4.0 allows utilities to accept arbitrary values dynamically without configuration or arbitrary value syntax. This applies to grid columns, spacing utilities, and custom data attributes.
- Grid columns: Use any number directly (e.g.,
grid-cols-15). - Data attributes: Target custom boolean data attributes directly (e.g.,
data-current:opacity-100). - Spacing: Utilities like
px-*,mt-*,w-*,h-*accept any integer value derived from the--spacingCSS variable.
The upgrade tool can automatically simplify arbitrary values that are no longer needed.
<!-- Grid of any size --> <div class="grid grid-cols-15"> <!-- ... --> </div> <!-- Target custom data attribute --> <div data-current class="opacity-75 data-current:opacity-100"> <!-- ... --> </div> <!-- Dynamic spacing --> <div class="mt-8 w-17 pr-29"> <!-- ... --> </div>- Grid columns: Use any number directly (e.g.,
Remove box shadows and rings
mainUse
shadow-noneto remove standard box shadows,inset-shadow-nonefor inset shadows,ring-0to remove rings, andinset-ring-0to remove inset rings. These utilities are useful for overriding previous shadow or ring styles.<!-- Remove standard shadow --> <div class="shadow-none"></div> <!-- Remove ring --> <div class="ring-0"></div>Set minimum inline size with min-inline utilities
mainUse
min-inline-*utilities to set the minimum inline size of an element. These utilities map to the CSSmin-inline-sizeproperty and support spacing scale numbers, fractions, container scale breakpoints, viewport units, and arbitrary values.Spacing scale numbers: Use
min-inline-<number>(e.g.,min-inline-24,min-inline-64) to set a fixed minimum inline size based on the spacing scale.Fractions: Use
min-inline-<fraction>(e.g.,min-inline-1/2,min-inline-2/5) to set a percentage-based minimum inline size.Container scale: Use
min-inline-<size>(e.g.,min-inline-xs,min-inline-lg) to set a fixed minimum inline size based on the container scale breakpoints.Viewport units: Use
min-inline-full(100%),min-inline-screen(100vw),min-inline-dvw(100dvw),min-inline-lvw(100lvw),min-inline-lvh(100lvh),min-inline-svw(100svw), ormin-inline-svh(100svh).Special values: Use
min-inline-auto,min-inline-min(min-content),min-inline-max(max-content), ormin-inline-fit(fit-content).Custom values: Use arbitrary values like
min-inline-[220px]or custom CSS variables likemin-inline-[var(--my-size)].<div class="min-inline-80">Minimum inline size of 80 (spacing scale)</div> <div class="min-inline-1/2">Minimum inline size of 50%</div> <div class="min-inline-lg">Minimum inline size of 32rem (container scale)</div> <div class="min-inline-screen">Minimum inline size of 100vw</div> <div class="min-inline-[220px]">Minimum inline size of 220px (arbitrary)</div>Style based on forced-colors mode
mainUse the new
forced-colorsvariant to apply styles specifically when the user's operating system is in forced colors mode (high contrast). This helps ensure accessibility for users who rely on high-contrast themes. Useforced-colors:*prefix to target this state.<!-- Style only in forced colors mode --> <div class="forced-colors:border-white">Content</div>Apply responsive contrast filters
mainYou can apply contrast filters responsively by combining
contrast-*utilities with responsive prefixes (e.g.,sm:,md:,lg:). This allows you to change the contrast level based on the viewport size.Example: Apply
contrast-125by default andcontrast-150on medium screens and up.<!-- Default: 125% contrast, Medium screens+: 150% contrast --> <img class="contrast-125 md:contrast-150" src="/img/mountains.jpg" />Control flex item shrinking with shrink utilities
mainUse the
shrinkutility class to allow a flex item to shrink if the container is too small. By default, flex items can shrink, but you can explicitly applyshrinkto ensure this behavior or useshrink-0to prevent shrinking entirely.Available classes:
shrink: Setsflex-shrink: 1(allows shrinking).shrink-<number>: Setsflex-shrinkto a specific number (e.g.,shrink-2).shrink-[<value>]: Setsflex-shrinkto an arbitrary value using bracket syntax (e.g.,shrink-[0.5]).shrink-(<custom-property>): Setsflex-shrinkto a CSS variable value (e.g.,shrink-(--my-var)).
Preventing shrinking: To ensure a flex item maintains its size and does not shrink, use
shrink-0.Responsive design: You can apply responsive modifiers to control shrinking behavior at different breakpoints (e.g.,
md:shrink-0to prevent shrinking on medium screens and larger).<!-- Allow shrinking (default behavior) --> <div class="flex"> <div class="w-14 flex-none">01</div> <div class="w-64 shrink">02</div> <div class="w-14 flex-none">03</div> </div> <!-- Prevent shrinking --> <div class="flex"> <div class="flex-1">01</div> <div class="w-32 shrink-0">02</div> <div class="flex-1">03</div> </div>