Setup, integration & interactivity.
Everything you need to start shipping with DuneUI. No package to install—just a recent version of Tailwind CSS v4, clean semantic markup, and optional JavaScript for interactive blocks.
Distribution
No npm package
Requirement
Tailwind CSS v4+
Interactivity
JS optional / per block
Frameworks
HTML · React · Vue · Astro
No npm package. Copy, paste, and own the code.
Unlike traditional UI component libraries, DuneUI is not distributed as an npm package. There is no npm install duneui command, no proprietary runtime, and no abstracted wrapper components hiding your markup inside node_modules.
Every component, template, and icon on DuneUI is authored as clean, transparent markup powered by standard Tailwind CSS v4 utilities (or standalone Pure CSS). Copy the specimen you need directly into your codebase, adapt the tokens or layout to match your brand, and ship zero unnecessary dependencies.
No Library Lock-In
No version conflicts or breaking library upgrades. Once copied, the HTML and classes belong entirely to your repository.
Full Markup Control
Inspect and modify every spacing utility, breakpoint, color token, and ARIA attribute directly in your own editor.
Works In Any Stack
Paste into plain HTML, React, Next.js, Vue, Nuxt, Astro, Svelte, Laravel Blade, Rails, or Django templates.
Requirements
Because DuneUI uses modern utility patterns and CSS-first tokens, make sure your project meets these baseline requirements before pasting Tailwind components:
Tailwind CSS v4.0 or newer
REQUIREDAll Tailwind-based DuneUI blocks are built for Tailwind CSS v4 (tested against v4.3+). They rely on v4 utilities like size-*, modern opacity modifiers, group-open:, data-* variants, and CSS-first @theme configuration. Projects still on Tailwind v3 should upgrade to v4 first or use our Pure CSS specimens.
JavaScript for interactive specimens
PER COMPONENTLayout and typographic blocks (cards, badges, heroes, footers, pricing) require zero JavaScript. However, one or more interactive components—such as dismissible alerts, dropdown menus, modals, drawers, tabs, toasts, and mobile navigation—require JavaScript logic to toggle state as shown in the live preview.
Inline SVG icons & system-friendly typography
INCLUDEDIcons are embedded directly as inline <svg> markup inside each snippet, so no external icon package is mandatory. You can swap them for lucide-react, lucide-vue-next, or Heroicons anytime.
Installing Tailwind CSS
Follow the official Tailwind CSS v4 installation workflow for your build tool. Choose your package manager and setup method below:
Installing Tailwind CSS as a Vite plugin is the fastest, most seamless setup for React, Vue, SvelteKit, Astro, Nuxt, and React Router.
Install Tailwind CSS and the Vite plugin
Install tailwindcss and @tailwindcss/vite via your package manager:
$npm install tailwindcss @tailwindcss/viteConfigure the Vite plugin
Add the @tailwindcss/vite plugin to your Vite configuration:
import { defineConfig } from 'vite'import tailwindcss from '@tailwindcss/vite'export default defineConfig({ plugins: [ tailwindcss(), ],})Import Tailwind CSS
Add an @import directive to your main CSS file. Tailwind v4 automatically scans your project templates—no tailwind.config.js content array needed:
@import "tailwindcss";Start your build process
$npm run devJavaScript & Interactive Components
While most DuneUI specimens are purely presentational HTML & CSS, several interactive components require JavaScript logic to behave identically to their live preview—such as dismissible alerts, dropdown menus, modals, drawers, tabs, command palettes, select menus, and toast notifications.
In our live specimen workbench, interactive previews execute scoped demo scripts inside an isolated iframe. When you switch to the Code tab or click Copy, preview-only <script> tags are automatically stripped so you receive clean markup ready for your application's own state management or event handlers.
Native HTML Primitives
Accordions built with <details> & <summary>, CSS peer-checked: toggles, and native Popover API work with zero JS.
data-* & ARIA Hooks
Interactive HTML snippets include semantic data-* hooks and aria-expanded attributes you can bind in ~10 lines of vanilla JS.
State or Headless UI
In React, Vue, or Svelte, drive visibility with useState / ref, or pair with Headless UI for focus trapping & portals.
EXAMPLE A — ZERO-JS NATIVE DISCLOSURE
<details class="group border-b border-slate-200 pb-4"> <summary class="flex cursor-pointer items-center justify-between font-semibold"> <span>Do I need JavaScript for this accordion?</span> <span class="transition-transform duration-200 group-open:rotate-180">↓</span> </summary> <p class="mt-3 text-sm text-slate-600"> No. Native HTML disclosure works out of the box with Tailwind's group-open variant. </p></details>EXAMPLE B — WIRING A DISMISSIBLE COMPONENT WITH VANILLA JS
<!-- 1. Paste the clean DuneUI HTML markup --><div role="alert" data-alert-root class="rounded-xl border border-slate-200 bg-white p-4"> <div data-alert-body class="flex items-start justify-between gap-4"> <div> <strong class="text-sm font-semibold text-slate-900">Deployment ready</strong> <p class="mt-1 text-xs text-slate-600">Edge build propagated in 1.4s.</p> </div> <button type="button" data-alert-dismiss aria-label="Dismiss alert" class="text-xs font-medium text-slate-500 hover:text-slate-900"> Dismiss </button> </div></div><!-- 2. Wire behavior in your app script (e.g. main.js) --><script type="module"> document.querySelectorAll('[data-alert-root]').forEach((root) => { const dismiss = root.querySelector('[data-alert-dismiss]'); dismiss?.addEventListener('click', () => { root.setAttribute('hidden', ''); }); });</script>Choose your target stack
Using HTML
DuneUI snippets are written in standard HTML5, so they drop straight into static sites, Laravel Blade, Rails ERB, Django/Jinja, or HTMX partials without translation.
For interactive widgets like dropdowns, modals, or drawers, toggle the hidden attribute and aria-expanded state from a small module script, and always bind Escape and outside-click handlers for accessibility:
<!-- Dropdown markup + accessible toggle script for plain HTML / Blade / ERB --><div class="relative inline-block text-left" data-dropdown> <button type="button" data-dropdown-trigger aria-expanded="false" aria-haspopup="menu" class="inline-flex items-center gap-2 rounded-lg border border-slate-300 bg-white px-3.5 py-2 text-sm font-medium text-slate-900 shadow-xs hover:bg-slate-50" > <span>Options</span> <svg class="size-4 text-slate-500" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> <path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" /> </svg> </button> <div data-dropdown-menu role="menu" hidden class="absolute right-0 z-20 mt-2 w-48 rounded-lg border border-slate-200 bg-white p-1 shadow-lg" > <a href="#edit" role="menuitem" class="block rounded-md px-3 py-2 text-sm text-slate-700 hover:bg-slate-100">Edit</a> <a href="#duplicate" role="menuitem" class="block rounded-md px-3 py-2 text-sm text-slate-700 hover:bg-slate-100">Duplicate</a> </div></div><script type="module"> document.querySelectorAll('[data-dropdown]').forEach((root) => { const trigger = root.querySelector('[data-dropdown-trigger]'); const menu = root.querySelector('[data-dropdown-menu]'); if (!trigger || !menu) return; const setOpen = (open) => { trigger.setAttribute('aria-expanded', String(open)); menu.toggleAttribute('hidden', !open); }; trigger.addEventListener('click', (e) => { e.stopPropagation(); setOpen(menu.hasAttribute('hidden')); }); document.addEventListener('click', (e) => { if (!root.contains(e.target)) setOpen(false); }); document.addEventListener('keydown', (e) => { if (e.key === 'Escape') setOpen(false); }); });</script>TIP // OPTIONAL HTML HELPERS
x-data / x-show) or native HTML popovertarget attributes.Using React
To use DuneUI inside React 18/19 or Next.js, paste the markup into a JSX/TSX component and adjust standard HTML attributes to React's JSX equivalents. Replace any inline data-* script logic with React state hooks (useState, useEffect, useRef).
import { useEffect, useRef, useState } from "react";export function OptionsDropdown() { const [open, setOpen] = useState(false); const rootRef = useRef<HTMLDivElement>(null); useEffect(() => { const onPointerDown = (e: MouseEvent) => { if (rootRef.current && !rootRef.current.contains(e.target as Node)) { setOpen(false); } }; const onKeyDown = (e: KeyboardEvent) => { if (e.key === "Escape") setOpen(false); }; document.addEventListener("mousedown", onPointerDown); document.addEventListener("keydown", onKeyDown); return () => { document.removeEventListener("mousedown", onPointerDown); document.removeEventListener("keydown", onKeyDown); }; }, []); return ( <div ref={rootRef} className="relative inline-block text-left"> <button type="button" aria-expanded={open} aria-haspopup="menu" onClick={() => setOpen((prev) => !prev)} className="inline-flex items-center gap-2 rounded-lg border border-slate-300 bg-white px-3.5 py-2 text-sm font-medium text-slate-900 shadow-xs hover:bg-slate-50" > <span>Options</span> <svg className="size-4 text-slate-500" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> <path fillRule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clipRule="evenodd" /> </svg> </button> {open && ( <div role="menu" className="absolute right-0 z-20 mt-2 w-48 rounded-lg border border-slate-200 bg-white p-1 shadow-lg" > <a href="#edit" role="menuitem" className="block rounded-md px-3 py-2 text-sm text-slate-700 hover:bg-slate-100"> Edit </a> <a href="#duplicate" role="menuitem" className="block rounded-md px-3 py-2 text-sm text-slate-700 hover:bg-slate-100"> Duplicate </a> </div> )} </div> );}For production overlays (accessible Dialogs, Listboxes, Comboboxes, and Popovers with automatic focus trapping and keyboard navigation), you can optionally pair DuneUI's Tailwind classes with Headless UI or Lucide React:
$npm install @headlessui/react lucide-reactUsing Vue
Vue Single File Components (.vue) require almost zero markup conversion: standard class, for, and SVG kebab-case attributes (fill-rule, stroke-width) work unchanged inside <template>.
Bind interactive visibility with ref(), v-if, and @click:
<script setup lang="ts">import { onBeforeUnmount, onMounted, ref } from 'vue'const open = ref(false)const rootRef = ref<HTMLElement | null>(null)function onDocumentClick(event: MouseEvent) { if (rootRef.value && !rootRef.value.contains(event.target as Node)) { open.value = false }}function onKeyDown(event: KeyboardEvent) { if (event.key === 'Escape') open.value = false}onMounted(() => { document.addEventListener('click', onDocumentClick) document.addEventListener('keydown', onKeyDown)})onBeforeUnmount(() => { document.removeEventListener('click', onDocumentClick) document.removeEventListener('keydown', onKeyDown)})</script><template> <div ref="rootRef" class="relative inline-block text-left"> <button type="button" :aria-expanded="open" aria-haspopup="menu" @click="open = !open" class="inline-flex items-center gap-2 rounded-lg border border-slate-300 bg-white px-3.5 py-2 text-sm font-medium text-slate-900 shadow-xs hover:bg-slate-50" > <span>Options</span> <svg class="size-4 text-slate-500" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> <path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" /> </svg> </button> <div v-if="open" role="menu" class="absolute right-0 z-20 mt-2 w-48 rounded-lg border border-slate-200 bg-white p-1 shadow-lg" > <a href="#edit" role="menuitem" class="block rounded-md px-3 py-2 text-sm text-slate-700 hover:bg-slate-100">Edit</a> <a href="#duplicate" role="menuitem" class="block rounded-md px-3 py-2 text-sm text-slate-700 hover:bg-slate-100">Duplicate</a> </div> </div></template>Building complex accessible menus or modals in Vue 3 or Nuxt? Optionally install @headlessui/vue alongside Tailwind CSS v4:
$npm install @headlessui/vue lucide-vue-nextUsing Astro JS
DuneUI itself is built with Astro and Tailwind CSS v4. Following Astro's official styling guide, Tailwind v4 integrates directly via the Vite plugin (@tailwindcss/vite) rather than the legacy @astrojs/tailwind v3 integration. Static .astro templates ship 0 kB of client JavaScript by default.
Run the official Astro CLI integration command
Astro's astro add tailwind wizard automatically installs tailwindcss and @tailwindcss/vite, registers the Vite plugin in astro.config.mjs, and generates src/styles/global.css with @import "tailwindcss";:
$npx astro add tailwindImport src/styles/global.css in your Layout or pages
Import your global stylesheet inside the Astro frontmatter of your shared layout (e.g. src/layouts/Layout.astro) or individual .astro pages so Tailwind utilities are available everywhere:
---// src/layouts/Layout.astro (or src/pages/index.astro)import "../styles/global.css";---<html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" /> <title>Astro + DuneUI</title> </head> <body> <slot /> </body></html>Handle interactive DuneUI scripts & View Transitions
Once Tailwind CSS is imported, paste any DuneUI HTML block into your .astro files. For components requiring JavaScript when <ClientRouter /> (View Transitions) is enabled, re-run setup on astro:page-load with a data-bound guard so listeners don't bind twice—or hydrate a React/Vue island using client:load:
---// src/components/AlertBanner.astro — zero JS shipped until neededinterface Props { title?: string; message?: string;}const { title = 'Environment synced', message = '12 keys propagated across 4 edge regions.',} = Astro.props;---<div role="alert" data-alert-root class="rounded-2xl border border-slate-200 bg-white p-4 shadow-sm"> <div class="flex items-start justify-between gap-4"> <div> <strong class="text-sm font-semibold text-slate-900">{title}</strong> <p class="mt-1 text-xs text-slate-600">{message}</p> </div> <button type="button" data-alert-dismiss aria-label="Dismiss alert" class="rounded-lg px-2 py-1 text-xs font-medium text-slate-500 hover:bg-slate-100 hover:text-slate-900" > Dismiss </button> </div></div><script> function initAlerts() { document.querySelectorAll<HTMLElement>('[data-alert-root]').forEach((root) => { if (root.dataset.bound === 'true') return; root.dataset.bound = 'true'; root.querySelector('[data-alert-dismiss]')?.addEventListener('click', () => { root.setAttribute('hidden', ''); }); }); } initAlerts(); document.addEventListener('astro:page-load', initAlerts);</script>NOTE // LEGACY @ASTROJS/TAILWIND
@tailwindcss/vite (installed automatically by astro add tailwind). The older @astrojs/tailwind integration only supports Tailwind v3 and is deprecated for Tailwind v4 setups.Dark Mode, Typography & Pure CSS
Every DuneUI component supports Light, Muted, Dark, and Aurora Mesh preview stages. By default, Tailwind v4's dark: variant follows the user's OS preference (prefers-color-scheme). If your app uses a manual .dark class toggle on <html>, add @custom-variant dark right after your Tailwind import:
@import "tailwindcss";/* Optional: enable class-based dark mode (.dark on <html>) */@custom-variant dark (&:where(.dark, .dark *));/* Optional: define custom typography & color tokens */@theme { --font-sans: "Inter", system-ui, sans-serif; --font-mono: "JetBrains Mono", ui-monospace, monospace;}Pure CSS Specimens
Working on a project without Tailwind CSS or Node tooling? Our Pure CSS suite ships standalone CSS rules and semantic HTML you can paste anywhere.
Open Pure CSS KitLicensing & FAQs
Free for unlimited personal, client, and commercial products with zero attribution required.