tailwind-elements-ui
v1.0.1
Published
Interactive UI components for Tailwind CSS — modals, dropdowns, carousels, tooltips, and more.
Maintainers
Readme
tailwind-elements-ui
Interactive UI components built for Tailwind CSS. Drop in modals, dropdowns, carousels, tooltips, and other behavior-driven elements without leaving your Tailwind workflow.
Version: 1.0.1
Features
- Tailwind CSS plugin with extended theme tokens (colors, shadows, animations)
- Auto-initializing JavaScript components via
data-twe-*attributes - ESM and UMD bundles with TypeScript declarations
- Dark mode support (
classstrategy) - Works with plain HTML, Vite, Webpack, Next.js, and other bundlers
Requirements
- Node.js 18+
- Tailwind CSS 3.x
Installation
npm install tailwind-elements-uiQuick start
1. Configure Tailwind
Add the plugin and scan component class names from the package:
// tailwind.config.js
module.exports = {
content: [
"./src/**/*.{html,js,jsx,ts,tsx}",
"./node_modules/tailwind-elements-ui/js/**/*.js",
],
plugins: [require("tailwind-elements-ui/plugin")],
darkMode: "class",
};Use
require("tailwind-elements-ui/plugin.cjs")if your config does not resolve the./pluginexport.
2. Import styles
Option A — compiled CSS (simplest)
import "tailwind-elements-ui/css";Option B — SCSS source (custom Tailwind pipeline)
@import "tailwind-elements-ui/src/css/tailwind.scss";3. Load JavaScript
Bundler (recommended)
import "tailwind-elements-ui";Components on the page are initialized automatically when the module loads.
Classic HTML
<script src="./node_modules/tailwind-elements-ui/js/tailwind-elements-ui.umd.min.js"></script>The UMD build attaches to window.tailwindElementsUi.
CDN usage
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/tailwind-elements-ui.min.css" />
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = { darkMode: "class" };
</script>
</head>
<body>
<!-- your markup -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/js/tailwind-elements-ui.umd.min.js"></script>
</body>Components (v1.0.1)
| Component | Purpose |
| ----------- | -------------------------------------------- |
| Button | Toggle active state on buttons |
| Collapse | Expand/collapse panels |
| Dropdown | Menus with Popper positioning |
| Modal | Dialog overlays with focus trap |
| Offcanvas | Slide-in panels |
| Carousel | Slideshow with touch support |
| Tooltip | Hover/focus tooltips |
| Popover | Click-triggered popovers |
| Tab | Tabbed navigation |
| ScrollSpy | Highlight nav items while scrolling |
| Input | Enhanced form inputs |
| Ripple | Material-style ripple effect |
Mark up elements with the documented data-twe-* attributes; the runtime wires up behavior on load.
Programmatic API
Import named exports when you need manual control:
import { Modal, Dropdown, init } from "tailwind-elements-ui";
const modal = Modal.getOrCreateInstance(document.getElementById("my-modal"));
modal.show();
init({ Modal, Dropdown }, { checkOtherImports: true });init(components?, options?)
| Option | Type | Default | Description |
| ------------------- | --------- | ------- | ------------------------------------------------ |
| allowReinits | boolean | false | Re-initialize components that were already set up |
| checkOtherImports | boolean | false | Warn when DOM nodes need a missing component |
Package exports
| Import path | Description |
| ------------------------------ | ------------------------------ |
| tailwind-elements-ui | ESM / UMD JavaScript bundle |
| tailwind-elements-ui/css | Minified stylesheet |
| tailwind-elements-ui/plugin | Tailwind CSS plugin |
| tailwind-elements-ui/plugin.cjs | Tailwind CSS plugin (CJS) |
Project structure
tailwind-elements-ui/
├── css/ # Compiled stylesheet
├── js/ # ESM + UMD bundles
├── types/ # TypeScript declarations
├── plugin.cjs # Tailwind plugin
└── src/css/ # SCSS entry for custom buildsLicense
MIT — see LICENSE.
