A lightweight, modular UI component library with zero dependencies.
StyleUI provides a comprehensive set of UI components built with vanilla JavaScript and CSS. Each component is carefully crafted to be accessible, performant, and easy to integrate into any web project.
<!-- Include CSS and JS bundles -->
<link rel="stylesheet" href="https://unpkg.com/styleui-components@latest/dist/styleui.css">
<script src="https://unpkg.com/styleui-components@latest/dist/styleui.min.js"></script>
<!-- Use components -->
<script>
const button = UI.button({ text: 'Click Me', variant: 'primary' });
document.body.appendChild(button);
</script>npm install styleui-componentsThen in your JavaScript:
// CommonJS
const { button, modal, toast } = require('styleui-components');
// ES Modules (with bundler)
import { button, modal, toast } from 'styleui-components';
// Use the components
const btn = button({ text: 'Click Me', variant: 'primary' });
document.querySelector('#app').appendChild(btn);Download the latest release from GitHub or get individual files from the dist/ directory.
StyleUI/
├── dist/ — Pre-built bundles for production use
│ ├── styleui.js — Full library
│ ├── styleui.min.js — Minified version (64KB)
│ ├── styleui.css — All styles bundled
│ └── styleui.esm.js — ES module exports
├── css/ — Modular stylesheets
├── components/ — Individual component files
├── sections/ — Demo page content generators
├── panels/ — Demo UI shell (not for production)
├── API.md — Complete API documentation
├── package.json — NPM package configuration
└── index.html — Live demo and style guide
- Foundations:
variables.css,base.css,typography.css,animations.css
Define design-tokens, resets, keyframes. - Components: one file per part (
button.css,card.css,panel.css, …).
No cross-file duplication. - Utilities / layout:
grid.css,scrollbars.css,mobile.css,patterns.css, etc.
Tip: import any subset in any order; component sheets rely only on the variables file.
Each file is an IIFE that attaches a single factory to the global UI namespace (e.g. UI.button, UI.toast). No DOM work happens automatically; functions return elements so consumers decide placement.
Shared helpers (UI.buildClasses, UI.icons, UI.deferIcons, config constants) live in components/core.js.
Files under sections/ create <section> elements that showcase a component group (buttons, cards, grid …). They import only the public UI.* factories—no side effects outside the demo container.
JavaScript that controls the left nav, header, right settings panel, and footer quick-settings. These are purely for the style-guide shell and are not part of the production library.
A static file referencing everything above with relative paths (no build step required). Open directly via file:// or serve with any static server.
- Add new tokens →
css/variables.css - Build a component
- CSS in
css/<component>.css - JS factory in
components/<component>.jsreturning an element
- CSS in
- Showcase it
- Create
sections/<component>s.jsthat calls the factory and appends a demo panel.
- Create
- Reference new files in
index.html(keep alphabetical order).
- Buttons - Standard, icon, toggle, and cycle buttons
- Cards - Flexible content containers with headers and actions
- Forms - Complete form controls including inputs, selects, checkboxes, date pickers
- Modals - Accessible modal dialogs with customizable actions
- Toasts - Non-blocking notifications with auto-dismiss
- Menus - Context menus and dropdowns
- Panels - Collapsible panels for content organization
- Trees - Hierarchical tree views with expand/collapse
- Timeline - Event timeline visualization
- Video Player - Custom video player with controls
- Markdown Editor - Live markdown editing with preview
- And more... - Tooltips, progress bars, spinners, tags
// Create a button
const saveBtn = UI.button({
text: 'Save Changes',
icon: 'save',
variant: 'primary',
onclick: () => handleSave()
});
// Show a toast notification
UI.toast('Changes saved successfully', { type: 'success' });
// Open a modal
const { modal, close } = UI.modal({
title: 'Confirm Delete',
content: 'This action cannot be undone.',
actions: [
{ text: 'Cancel', variant: 'neutral' },
{ text: 'Delete', variant: 'error', onclick: () => performDelete() }
]
});<!-- Latest version -->
<link rel="stylesheet" href="https://unpkg.com/styleui-components@latest/dist/styleui.css">
<script src="https://unpkg.com/styleui-components@latest/dist/styleui.min.js"></script>
<!-- Specific version -->
<link rel="stylesheet" href="https://unpkg.com/styleui-components@0.1.0/dist/styleui.css">
<script src="https://unpkg.com/styleui-components@0.1.0/dist/styleui.min.js"></script>- NPM: styleui-components
- CDN: unpkg.com/styleui-components
- Size: 65KB minified JS + 80KB CSS
- Dependencies: None
- API.md - Complete API reference with examples
- Live Demo - Interactive component showcase
- Zero Dependencies - No external libraries required
- Modern JavaScript - ES6+ with no transpilation needed
- Customizable - CSS variables for easy theming
- Chrome/Edge 88+
- Firefox 78+
- Safari 14+
- Mobile browsers with ES6 support
MIT
Questions or contributions? open an issue on the main repository.