Thanks for your interest in improving njX UI. Here's how to add components, fix bugs, or improve the library.
# Fork and clone
git clone https://github.com/YOUR_USERNAME/njx-css-ui.git
cd njx-css-ui
# Install dev tools (for building style.min.css)
npm installcss/
├── style.css ← entry point — only @import, no styles here
├── _base.css ← ALL design tokens (colors, spacing, fonts…)
│ edit this file to change variables globally
├── _buttons.css ← button components
├── _cards.css ← card variants
├── _form.css ← form elements
├── _nav.css ← navigation
├── _utils.css ← utility classes (Tailwind-style)
├── _animations.css ← @keyframes and animation classes
├── _hovers.css ← hover effects
├── _gradients.css ← gradient classes
└── ... ← other component files
js/
└── njx.js ← vanilla JS helpers (tabs, modal, accordion, toast)
Rule: never hardcode values. Always use variables from _base.css.
/* Wrong */
.my-component { color: #14a0ff; padding: 16px; border-radius: 12px; }
/* Correct */
.my-component { color: var(--color-primary); padding: var(--space-4); border-radius: var(--radius-md); }Create css/_mycomponent.css:
/* ============================================================
_mycomponent.css — Short description
============================================================ */
.my-component {
background: var(--color-primary-opacity);
color: var(--color-light);
padding: var(--space-4);
border-radius: var(--radius-md);
transition: var(--ease);
}
.my-component:hover {
box-shadow: var(--shadow-primary);
}Open css/style.css and add the import in the right section:
/* 3. Components */
@import "_buttons.css";
@import "_cards.css";
@import "_mycomponent.css"; /* ← add here */npm run build
# or
npx lightningcss --bundle --minify css/style.css -o css/style.min.cssOpen index.html in a browser and check your component looks right across themes:
// Test in browser console
['dark','light','red','blue','green','cyan','yellow','pink','purple'].forEach((t, i) => {
setTimeout(() => document.documentElement.setAttribute('data-theme', t), i * 800)
})Utility classes go in css/_utils.css. Follow the existing naming:
/* Display */
.d-block { display: block !important; }
/* Spacing — use --space-* variables */
.mt-4 { margin-top: var(--space-4) !important; }
.px-6 { padding-left: var(--space-6) !important; padding-right: var(--space-6) !important; }
/* Typography */
.text-primary { color: var(--color-primary) !important; }For responsive variants, add to css/_responsive.css following the sm:, md:, lg:, xl: pattern already there.
All tokens live in css/_base.css. To add a new variable:
:root {
/* add your token here */
--my-new-token: value;
}If the token needs to change per theme, add it to each [data-theme="..."] block too.
git checkout -b feat/my-new-componentFollow the rules above. Build the minified file:
npm run buildgit add css/_mycomponent.css css/style.css css/style.min.css
git commit -m "feat: add MyComponent"git push origin feat/my-new-component- Go to your fork on GitHub
- Click Compare & pull request
- Describe what you added and why
- Submit
feat: add slider component
fix: button outline border on dark theme
docs: update README with new examples
refactor: move keyframes to _animations.css
Types: feat · fix · docs · refactor · chore
- No hardcoded colors or sizes — use variables
- No external dependencies
- Every component must work across all 9 themes
style.min.cssmust be rebuilt before committing- One component per file, one PR per feature