How these Tailwind examples are built
Every demo is built with Tailwind CSS v4.3 and compiled with the official Tailwind CLI, so each page ships only the utilities its demos use. Each demo renders in its own sandboxed frame, so you see exactly what the classes produce, with no theme styles leaking in. Click, type and tab through a demo, then copy its HTML, CSS and JavaScript from the panel underneath.
The demos follow the same rules across all pages:
- Utilities first: variants such as hover, focus-visible, peer, group, has and aria do the work, and custom CSS only covers what utilities cannot express.
- Native elements before scripts: dialog, details, the Popover API and real form controls, with a little vanilla JavaScript only where the pattern needs it. No plugins and no component libraries.
- Keyboard and screen reader support: labels on every field, the ARIA states the pattern calls for and visible focus styles.
- Every demo is checked at phone width, dark variants follow a .dark class, and custom motion sits behind motion-safe.
After the demos, each page has a guide to the utilities, browser support and accessibility details behind them. Prefer a framework with ready-made components? The Bootstrap examples cover similar patterns, and the CSS examples do it in plain CSS.
What are Tailwind CSS examples?
Tailwind CSS examples are finished interface patterns, such as navbars, cards and pricing tables, built entirely from utility classes in HTML markup. Copy the code, change the text, and the layout renders without a separate stylesheet.
Two things get confused with them. A documentation snippet shows one utility in isolation, and a setup example shows how to install Tailwind in a framework. Neither gives you a screen to ship.
Examples come in three sizes, and the size decides where you look first.
Components
Single elements: navbar, card, modal, contact form, dropdown.
These are the smallest unit. Most are one block of markup that drops into an existing page without touching the rest of it.
Page sections
Sections are full-width bands that stack into a landing page.
- Hero
- Feature grid
- Pricing table
- Testimonials
- Footer
A section bundles several components, so it carries more responsive classes than a single card does.
Full templates
Templates save the most time and cost the most flexibility.
A template is a complete landing page, dashboard layout or storefront. Preline UI ships them, as Tailwind Plus did, and you inherit someone else's file structure, class habits and framework choice along with the design.
Where to find Tailwind CSS examples, free and paid
Tailwind Plus was the official paid source until it closed to new sign-ups in September 2026, and Preline UI, HyperUI, Flowbite, daisyUI and shadcn/ui cover most free needs. They differ in how the code reaches your project, which matters more than the component count.
| Source | How you get the code | Cost and license |
|---|
| Tailwind Plus | Copy-paste components and templates in React, Vue and HTML | Paid, one-time purchase, closed to new sign-ups since September 2026 |
| Preline UI | Copy-paste blocks plus JavaScript plugins | Free core, paid Pro tier |
| Flowbite | Components plus a JavaScript library for interactive parts | Open source, paid Pro tier |
| HyperUI | Copy-paste HTML, some with Alpine JS | Free, MIT license |
| shadcn/ui | Source code copied into your repo by a CLI | Free, open source |
Official collection
A Tailwind Plus license covered 500+ components and templates plus the Catalyst UI Kit, per Tailwind Labs' checkout page. Components came in React, Vue and plain HTML. Sign-ups closed on September 9, 2026, after Tailwind Labs joined Shopify.
Tailwind Play, the official browser playground, runs Tailwind's build-time features and shares a snapshot by link with no account (Tailwind Labs blog). It is the fastest place to test any pasted example.
Free libraries
Preline UI
Preline's homepage lists 640+ free components and 220+ free blocks (Preline UI, October 2026).
Dropdowns, modals and tabs come from its headless JavaScript plugins.
HyperUI
HyperUI works as a copy-and-paste shelf, according to its GitHub README.
- MIT license
- No installation
- Preview at sm, md and lg breakpoints before copying
- Some components use Alpine JS
Flowbite
Flowbite adds a JavaScript layer for dropdowns, modals and other interactive elements, loaded next to its Tailwind plugin (Flowbite documentation). Setup for Tailwind v4 uses a @plugin line in your CSS file.
Pick it when you want those behaviors working on day one.
daisyUI
daisyUI is a Tailwind plugin that adds semantic classes such as btn and card, so the markup stays short.
The trade-off is readability. The HTML stops showing what each element does in utility terms, and the library ships CSS classes only, with no React or Vue components.
shadcn/ui
The shadcn/ui CLI copies component source into your repository, and you edit that code directly (shadcn/ui documentation).
Maintenance moves to you too. Nothing arrives through a package update.
Which source fits which project
- Prototype or learning: HyperUI or the free Preline blocks, tested in Tailwind Play first.
- One client site: Tailwind Plus if you already hold a license, because it allows a custom website built for a single client. New buyers can no longer sign up, so start from a free library instead.
- Resold templates: not Tailwind Plus. Use an MIT-licensed source and read the license of every piece you paste.
- Interactive parts without custom JavaScript: Flowbite or Preline.
Teams building their own design system get the most from shadcn/ui, since the code ends up in their repo.
For a one-off landing page, free blocks cover the same sections a paid kit would.
Can you use Tailwind CSS examples in client and commercial work?
Yes, within the limits of each source's license. Tailwind Plus allows a custom site built for a single client and bans reselling its code to multiple clients or repackaging it as a UI kit.
Allowed under Tailwind Plus:
- A custom website for one client
- Edited components and templates, which stay under the same license
Banned under Tailwind Plus:
- Selling a site or template built from the code to multiple clients
- Publishing a public repository of the components or their derivatives
- Building a UI library, free or for sale, from the components
- Derivative products such as themes, UI kits or page builders
Customers of a software-as-a-service product do not count as clients under the license (Tailwind Plus license page).
A public repository of Tailwind Plus code is listed as a banned use. Open-source projects should read the full license before pasting anything.
Cost was a one-time purchase with lifetime access and no subscription, per Tailwind Labs. Checkout pages listed $299 for an individual license before sign-ups closed, and existing licenses keep the same terms.
Free libraries vary. HyperUI publishes under the MIT license, which permits reuse as long as the copyright notice stays, according to its README. Check the license file in each repository before reuse.
How utility classes build a Tailwind CSS example
Every visual rule in an example sits on the element as a class: layout, spacing, type, color and state. Read the class list left to right and you can rebuild what the element looks like.
A small profile card shows the pattern.
<div class="flex items-center gap-4 rounded-xl bg-white p-6 shadow-md">
<img class="size-12 rounded-full" src="avatar.jpg" alt="">
<div>
<p class="text-lg font-semibold text-gray-900">Ana Pop</p>
<p class="text-sm text-gray-500">Front-end developer</p>
</div>
</div>
- Layout: flex and items-center put the avatar and text in one row, centered vertically
- Spacing: gap-4 separates the children, p-6 pads the card
- Surface: rounded-xl, bg-white and shadow-md draw the card
- Type: text-lg, font-semibold and text-gray-900 style the name
Flex or grid
Flex: one row or one column of items, like a navbar or the card above.
Grid: rows and columns together, like a card gallery or a dashboard.
Mixing both is normal. A dashboard shell is a grid, and each card inside it is a flex container.
Hover and focus states
States stack as prefixes on the same element.
A class like hover:underline applies only on hover, and prefixes combine, so md:hover:underline applies on hover at the md breakpoint and up. The same prefix pattern drives breakpoints and dark mode, which the next sections cover.
The cost of long class lists
- The same long class string gets pasted into every card
- A design change means editing every copy
- Scanning a page for one stray class takes longer than reading a stylesheet
How breakpoint prefixes make examples responsive
A utility without a prefix applies on every screen, and a prefixed utility such as md:flex applies from that breakpoint upward. Examples are built mobile-first, so the phone layout comes first and larger screens layer changes on top.
| Prefix | Minimum width | Media query |
|---|
| sm | 40rem (640px) | @media (width >= 40rem) |
| md | 48rem (768px) | @media (width >= 48rem) |
| lg | 64rem (1024px) | @media (width >= 64rem) |
| xl | 80rem (1280px) | @media (width >= 80rem) |
| 2xl | 96rem (1536px) | @media (width >= 96rem) |
These are the defaults in the Tailwind CSS documentation for v4.3 as of October 2026. Tailwind's v2 documentation listed the same widths in pixels only, so older examples and tutorials quote px values while the current docs define them in rem.
Reading a responsive example
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
One column below 40rem, two columns from 40rem, three columns from 64rem. Each prefix only states where a change starts, never where it stops.
Mistakes that break pasted examples
- Using sm: for phones. The sm: prefix means "at the small breakpoint and up", so style mobile with the unprefixed class, as in text-center sm:text-left.
- Missing viewport tag. The docs require a viewport meta tag in the page head, and without it phone browsers render at desktop width.
Ranges, custom breakpoints and container queries
Stack a breakpoint with a max-* variant to limit a style to a range. The class md:max-xl:flex applies only between 48rem and 80rem.
Custom breakpoints go in the CSS file through theme variables, such as --breakpoint-3xl: 120rem. Use the same unit as the defaults, because mixing units can reorder the generated utilities so breakpoint classes override each other (Tailwind CSS documentation).
Components that sit in sidebars or narrow columns respond to their parent instead of the screen with container queries, marked by the @container class and variants like @md:flex-row.
Dark mode in Tailwind CSS examples: system setting or manual toggle?
By default, dark: classes follow the visitor's operating system setting through the prefers-color-scheme media query. A manual toggle needs one line of CSS that overrides the dark variant (Tailwind CSS dark mode documentation).
Pasted dark mode examples fail when the markup assumes one approach and your project uses the other.
System setting, the default
<div class="bg-white text-gray-900 dark:bg-gray-800 dark:text-white">
No JavaScript and no configuration. The catch is control: visitors get whatever their OS reports and cannot switch on your site.
Manual toggle with a class
Override the dark variant in your main CSS file, and dark: utilities apply whenever a dark class sits earlier in the HTML tree.
@import "tailwindcss";
@custom-variant dark (&:where(.dark, .dark *));
How the class reaches the html element is up to you. The docs suggest a small script that syncs the choice to localStorage, and Preline's own homepage does exactly that.
Data attributes and three-way toggles
Data attribute: swap the selector for [data-theme=dark], and the same dark: classes respond to data-theme="dark" on any ancestor.
Light, dark and system: store "light" or "dark" in localStorage, delete the key to follow the OS, and read the system value with window.matchMedia().
Run that script inline in the head. A script that loads later flashes the wrong theme first.
Why a pasted dark mode example does nothing
- The markup expects a toggle class, but your CSS never declares the override
- Nothing ever adds the dark class to the html element
- The example came from v3, where darkMode lived in tailwind.config.js, and v4 no longer detects that file automatically
- Scrollbars and form controls stay light until you add the color-scheme utilities introduced in v4
Older tutorials also use two names for one idea. In v3, the selector strategy replaced the class strategy in version 3.4.1 (Tailwind v3 documentation).
Do Tailwind CSS examples written for v3 work in v4?
Not unchanged. Renamed utilities and changed defaults alter how a v3 example looks in v4, and the v3 setup lines no longer work as written (Tailwind CSS upgrade guide).
Tailwind CSS v4.0 shipped in January 2025. The repository changelog dates the tag January 21, and the announcement post carries January 22.
| Item | v3 example | v4 equivalent |
|---|
| Stylesheet setup | @tailwind base; @tailwind components; @tailwind utilities; | @import "tailwindcss"; |
| Shadow and radius names | shadow-sm, shadow, rounded-sm, rounded | shadow-xs, shadow-sm, rounded-xs, rounded-sm |
| Focus outline reset | focus:outline-none | focus:outline-hidden |
| Ring | ring | ring-3 |
| Opacity utilities | bg-opacity-50 | bg-black/50 |
The bare v3 names still resolve, so a pasted shadow-sm renders. It just renders at the size v3 called shadow.
Setup lines that break
- @tailwind directives: removed, replaced by a single @import
- tailwind.config.js: no longer detected automatically, so load it with @config if you keep it
- PostCSS plugin: now lives in @tailwindcss/postcss, and Vite projects use @tailwindcss/vite instead
Defaults that change without an error
Nothing throws. The example just looks slightly off.
- Border and divide utilities default to currentColor instead of gray-200, so add border-gray-200 where the example relied on it
- The default ring color moved from blue-500 to currentColor
- Buttons use the default cursor, not the pointer
- The hover variant applies only on devices that support hover, which breaks hover-only menus on touch screens
What the upgrade tool covers
Running npx @tailwindcss/upgrade migrates dependencies, config and template files in a v3 project. It needs Node.js 20 or higher, and Tailwind recommends running it on a new branch and reviewing the diff.
The tool runs once, against your existing code. An example you paste afterward is yours to convert by hand.
The browser floor is the other hard limit: v4.0 targets Safari 16.4, Chrome 111 and Firefox 128 or newer (Tailwind CSS compatibility documentation). Older targets stay on v3.4.
How to add a Tailwind CSS example to a React, Vue, Next.js or HTML project
Set up Tailwind in the project first, then paste the example and adapt its syntax to your framework. Vite is the shortest route, and Next.js, Nuxt, Astro, SvelteKit and React Router each have their own guide in the Tailwind docs.
- Paste the example into Tailwind Play and confirm it renders like the library's preview. A broken class or a missing script shows up there before it touches your project.
- Install Tailwind for your stack. With Vite, run
npm install tailwindcss @tailwindcss/vite, add tailwindcss() to the plugins array in vite.config, and put @import "tailwindcss"; in your CSS file. - Paste the markup into a component. React and Next.js need className instead of class, while Vue and plain HTML keep class.
- Load what the example depends on. Interactive pieces need their script, and classes that live outside your source files need a source path, such as
@source "../node_modules/flowbite";. - Scan the markup for v3 patterns before the first render.
- Drag the browser through the breakpoints, then flip dark mode once.
Step 4 exists because v4 detects template files automatically but skips anything in .gitignore and all binary files (Tailwind CSS v4.0 announcement).
Plain HTML: build with the Tailwind CLI, npx @tailwindcss/cli -i input.css -o output.css, or try the browser build first. The @tailwindcss/browser package arrived in v4.0.0-beta.9 (repository changelog, January 9, 2025).
Vue: use the Vite route or the Nuxt guide, and keep styling as classes in the template. If a style block must use @apply, add @reference "../app.css"; at the top so it can see your theme variables.
Next.js: follow its framework guide, then paste examples as JSX.
When Tailwind CSS examples are the wrong starting point
Skip copy-paste examples when your browser targets predate v4, when your stack leans on Sass or CSS modules, or when you need only two or three components. In those cases the example costs more to adapt than to write.
Tooling that does not fit
- Older browser targets: projects below the v4 floor stay on v3.4, so v4-era markup is the wrong base.
- Sass, Less and Stylus: v4 is not designed to work with preprocessors, so tutorials built on Sass with @apply do not carry over.
- CSS modules: each file is processed separately, so a project with 50 CSS modules makes Tailwind run 50 times (Tailwind CSS compatibility documentation).
Behavior and accessibility gaps
A copied example gives you markup, not behavior.
Modals and dropdowns look finished and do nothing until their script loads, and Flowbite, Preline and the Alpine-based HyperUI components each handle that in their own way.
Accessibility hides in one class. A v3 focus:outline-none left an invisible outline that still appeared in forced colors mode, while v4's outline-none removes the outline outright and the old behavior moved to outline-hidden (Tailwind CSS upgrade guide).
Tab through every pasted form control before shipping.
Paste or write
Paste when:
- The pattern is standard, like a footer or pricing table
- Your project already meets the v4 browser floor
Write from the docs when:
- You need two or three components
- Adapting the example means changing its syntax, its scripts and its class names
- The tutorial predates v4: Tailwind Labs archived its framework setup examples repository on May 8, 2021, and it is read-only
For a single pricing section, writing it from the documentation's own markup takes less time than learning a library's JavaScript API.
Tailwind CSS Examples FAQ
Is Tailwind CSS itself free to use?
Yes. The framework is open source under the MIT license, according to its GitHub repository.
Paid parts are separate products, such as Tailwind Plus, and none of them is required to run an example.
Which editor extension autocompletes Tailwind classes?
The official Tailwind CSS IntelliSense extension for Visual Studio Code. It adds autocomplete, linting, syntax highlighting for at-rules like @theme, and hover previews that show the CSS behind each class (Tailwind CSS editor setup documentation).
Zed builds the support in, and JetBrains IDEs include it.
How do I sort the long class lists in a pasted example?
Install the official Prettier plugin for Tailwind CSS. It reorders classes into Tailwind's recommended order wherever Prettier runs, from editors to the command line.
Pasted examples then match the class order in the rest of your code.
Does Tailwind CSS have its own icon set?
Yes. Heroicons comes from the makers of Tailwind CSS, with 316 hand-crafted SVG icons under the MIT license.
The set ships in outline, solid, mini and micro styles, plus React and Vue libraries (Heroicons, v2.2.0).