nought.css ~6KB nought.js ~2.2KB

Build UIs with
Nought

A complete UI library in ~8KB. No React. No Vue. No build step. No node_modules. Just 2 tiny files and semantic HTML.

~8KB
Total Size (gzipped)
25+
Components
0
Dependencies
2
Files

Get Started

Drop two files into your project. That's it. No npm, no webpack, no config.

HTML
<link rel="stylesheet" href="nought.css">
<script src="nought.js"></script>
Or use a CDN (coming soon)
<link rel="stylesheet" href="https://unpkg.com/nought-ui/nought.css">
<script src="https://unpkg.com/nought-ui/nought.js"></script>
Nought uses custom elements — lightweight, SSR/RSC-compatible, progressively enhanced. Wrap your markup in <n-tabs>, <n-accordion>, etc. and interactivity is automatic. Works in React Server Components, Astro, plain HTML — everywhere.

Buttons

Semantic button variants with hover states, focus rings, and keyboard support.

<button class="n-btn">Primary</button>
<button class="n-btn n-btn-secondary">Secondary</button>
<button class="n-btn n-btn-outline">Outline</button>
<button class="n-btn n-btn-ghost">Ghost</button>
<button class="n-btn n-btn-danger">Danger</button>
<button class="n-btn n-btn-success">Success</button>
<button class="n-btn n-btn-sm">Small</button>
<button class="n-btn n-btn-lg">Large</button>

API

CSS Custom Properties

VariableRole
--n-primaryPrimary button background
--n-primary-hoverPrimary hover background
--n-primary-textText color on primary
--n-dangerDanger button background
--n-successSuccess button background
--n-radiusBorder radius
--n-ringFocus ring color
--n-transitionHover / focus transition

Cards

Versatile content containers with optional hover effects.

Simple Card

Clean and minimal card component with hover effect.

New

Feature Card

With badge, title and description layout.

Card body content.

<div class="n-card n-card-hover">
  <div class="n-card-header">Title</div>
  <div class="n-card-body">Content</div>
  <div class="n-card-footer">Footer</div>
</div>

API

CSS Custom Properties

VariableRole
--n-surfaceCard background
--n-border-lightCard border and dividers
--n-radius-lgCard border radius
--n-shadow-mdHover shadow
--n-transitionHover transition

Badges & Tags

Small status indicators and categorization labels.

Default Success Warning Danger Info Solid
HTML CSS JavaScript

API

CSS Custom Properties

VariableRole
--n-primary / --n-primary-lightDefault badge colors
--n-success / --n-success-lightSuccess variant colors
--n-warning / --n-warning-lightWarning variant colors
--n-danger / --n-danger-lightDanger variant colors
--n-info / --n-info-lightInfo variant colors
--n-radius-fullBadge border radius (pill shape)

Alerts

Contextual feedback messages with semantic border accents.

This is a default informational alert.
Changes saved successfully!
Your session will expire in 5 minutes.
Failed to delete the resource. Please try again.
<div class="n-alert n-alert-success">
  Changes saved successfully!
</div>

API

CSS Custom Properties

VariableRole
--n-primary / --n-primary-lightDefault alert accent and background
--n-success / --n-success-lightSuccess variant colors
--n-warning / --n-warning-lightWarning variant colors
--n-danger / --n-danger-lightDanger variant colors
--n-radiusAlert border radius

Forms

Accessible form controls with validation states and custom switches.

Enter your legal name

Please enter a valid email address

<div class="n-field">
  <label class="n-label" for="name">Name</label>
  <input class="n-input" type="text" id="name">
  <p class="n-hint">Helper text</p>
</div>

<label class="n-switch">
  <input type="checkbox">
  <span class="n-switch-track"></span>
  <span>Label</span>
</label>

API

CSS Custom Properties

VariableRole
--n-bgInput background
--n-borderInput border color
--n-radiusInput border radius
--n-primaryFocus border and checked state
--n-ringFocus ring color
--n-dangerError state color
--n-text-mutedHint text color
--n-transitionFocus / hover transition

Table

Responsive, hover-enabled data tables.

NameRoleStatusAction
Alice ChenEngineerActive
Bob SmithDesignerActive
Carol WhitePMAway
David ParkDevOpsOffline

API

CSS Custom Properties

VariableRole
--n-border-lightCell borders
--n-bg-altHeader background
--n-bg-hoverRow hover background
--n-radiusTable border radius

Progress

Slim progress bars with color variants.

Uploading...72%

API

CSS Custom Properties

VariableRole
--n-primaryDefault bar color
--n-successSuccess bar color
--n-dangerDanger bar color
--n-bg-hoverTrack background
--n-radius-fullBar border radius

Avatars

User representations with initials, images, and groups.

S RC LG User User
User User User +3

API

CSS Custom Properties

VariableRole
--n-primary-lightAvatar background (initials)
--n-primaryAvatar text color (initials)
--n-bgAvatar group border color

Kbd & Code

Keyboard shortcut indicators and inline code styling.

Press Ctrl + S to save. Use console.log() for debugging.

const greet = (name) => {
  return `Hello, ${name}!`;
};

console.log(greet('Nought'));

API

CSS Custom Properties

VariableRole
--n-monoMonospace font family
--n-bg-altCode / kbd background
--n-border-lightKbd border color
--n-radius-smCode border radius

Tooltips

CSS-only tooltips using aria-label — accessible by default.

<span class="n-tooltip" aria-label="Tooltip text">
  <button class="n-btn">Hover me</button>
</span>

API

HTML Attributes

AttributeDescription
aria-labelTooltip text (used as content, accessible by default)

CSS Custom Properties

VariableRole
--n-textTooltip background (inverted)
--n-bgTooltip text color (inverted)
--n-radius-smTooltip border radius

Skeleton

Animated loading placeholders.

API

CSS Custom Properties

VariableRole
--n-bg-hoverSkeleton base color
--n-bg-altShimmer highlight color
--n-radius-smSkeleton border radius

Spinner

Loading indicators in multiple sizes.

API

HTML Attributes

AttributeDescription
role="status"Announces loading state to screen readers
aria-label="Loading"Accessible label

CSS Custom Properties

VariableRole
--n-primarySpinner color
--n-borderSpinner track color

List

Structured list items with hover states.

  • A
    Alice Chen
    alice@example.com
    Active
  • B
    Bob Smith
    bob@example.com
    Away
  • C
    Carol White
    carol@example.com
    Offline

API

CSS Custom Properties

VariableRole
--n-border-lightItem borders
--n-bg-hoverItem hover background

Tabs

Keyboard-navigable tabbed interface with ARIA roles.

Nought provides a complete set of production-ready components in under 8KB. Ship faster with semantic HTML.

25+ components, dark mode, ARIA-first accessibility, CSS custom properties for theming, and zero dependencies.

Free. Open source. MIT licensed. Forever.

<!-- Custom element: works in RSC, SSR, plain HTML -->
<n-tabs>
  <div class="n-tabs" role="tablist">
    <button class="n-tab active" role="tab"
      aria-selected="true" aria-controls="panel-id">
      Tab Label
    </button>
  </div>
  <div id="panel-id" class="n-tab-panel active"
    role="tabpanel">Content</div>
</n-tabs>

API

HTML Attributes

AttributeElementDescription
role="tablist"Tab barARIA tablist role
role="tab"Tab buttonARIA tab role
aria-selectedTab buttonSet to "true" on the active tab
aria-controlsTab buttonID of the panel this tab controls
role="tabpanel"PanelARIA tabpanel role

Keyboard

KeyAction
ArrowRightMove to next tab
ArrowLeftMove to previous tab

CSS Custom Properties

VariableRole
--n-primaryActive tab indicator color
--n-text-secondaryInactive tab text color
--n-border-lightTab bar border
--n-transitionHover / active transition

Accordion

Collapsible content sections with smooth animations.

A complete UI library in ~8KB. Two files — one CSS, one JS — that give you 25+ production-ready components with dark mode and full accessibility.
No! Nought works with plain HTML files. Drop in the CSS and JS files, write semantic markup, and you're done. No webpack, no npm, no config.
Yes. Every component is built ARIA-first with proper roles, keyboard navigation, focus management, and screen reader support baked in.
<!-- Custom element: server-renders as-is -->
<n-accordion>
  <div class="n-accordion-item">
    <button class="n-accordion-trigger"
      aria-expanded="false">Question?</button>
    <div class="n-accordion-content">
      <div class="n-accordion-content-inner">
        Answer.
      </div>
    </div>
  </div>
</n-accordion>

API

HTML Attributes

AttributeElementDescription
multiple<n-accordion>Allow multiple items open at once
aria-expandedTrigger buttonSet to "true" to render an item open on load

CSS Custom Properties

VariableRole
--n-border-lightItem borders
--n-radiusContainer border radius
--n-bg-hoverTrigger hover background
--n-transitionExpand / collapse transition

Toast

Non-blocking notification messages via the JS API.

<!-- Place once in your HTML -->
<n-toast-area></n-toast-area>

// Show via the element API:
document.querySelector('n-toast-area').show('Saved!', 'success');

// Or the global shortcut:
Nought.toast.show('Saved!', 'success');
Nought.toast.show('Error!', 'danger');
Nought.toast.show('Warning!', 'warning', 6000);

API

JavaScript

TypeNameDescription
Methodshow(message, type?, duration?)Show a toast. type: "success" | "danger" | "warning" | "info" (default). duration: ms, default 4000. Set 0 to persist.
MethodNought.toast.show()Global shortcut — auto-creates <n-toast-area> if not present

CSS Custom Properties

VariableRole
--n-surfaceToast background
--n-shadow-lgToast box shadow
--n-radiusToast border radius
--n-successSuccess border accent
--n-dangerDanger border accent
--n-warningWarning border accent
--n-infoInfo border accent

Drawer

Slide-out panel for secondary content or navigation.

<!-- Custom element: SSR/RSC compatible -->
<n-drawer>
  <div class="n-drawer-overlay"></div>
  <aside class="n-drawer">
    <div class="n-drawer-header">
      <h3>Title</h3>
      <button data-drawer-close>&times;</button>
    </div>
    <div class="n-drawer-body">Content</div>
  </aside>
</n-drawer>

<!-- Open/close via JS: -->
<script>
  document.querySelector('n-drawer').open();
  document.querySelector('n-drawer').close();
</script>

API

JavaScript

TypeNameDescription
Methodopen()Opens the drawer
Methodclose()Closes the drawer, restores focus
EventopenFired after the drawer opens
EventcloseFired after the drawer closes
Attributedata-drawer-closeOn a button — closes the parent drawer

Keyboard

KeyAction
EscapeClose the drawer

CSS Custom Properties

VariableRole
--n-surfaceDrawer background
--n-shadow-lgDrawer box shadow
--n-border-lightHeader border

Dark Mode

System-aware theming that respects prefers-color-scheme with manual override.

Click the sun icon in the navbar to toggle dark mode. Nought stores the preference in localStorage and auto-detects system theme.
<!-- Custom element: auto-detects system theme -->
<n-theme-toggle aria-label="Toggle dark mode">
  🌓 Toggle Theme
</n-theme-toggle>

// Or customize theming via CSS custom properties:
:root {
  --n-primary: #your-brand-color;
}

API

Custom Element

TagDescription
<n-theme-toggle>Click to toggle between light and dark mode. Auto-detects system preference on load.

HTML Attributes

AttributeElementDescription
data-theme<html>Set to "dark" or "light". Toggled automatically.
aria-pressed<n-theme-toggle>Reflects current dark mode state

JavaScript

TypeNameDescription
MethodNought.darkMode.init()Apply stored or system theme (called automatically on load)

Storage

KeyValuesDescription
n-theme"light" | "dark"Persisted in localStorage. Falls back to prefers-color-scheme.

Layout & Grid

Responsive grid system and flex utilities.

1/4
2/4
3/4
4/4
1/3
2/3
3/3
1/2
2/2
<div class="n-grid n-cols-3">
  <div>Column 1</div>
  <div>Column 2</div>
  <div>Column 3</div>
</div>

<div class="n-container">
  <div class="n-flex n-flex-between">...</div>
</div>

API

Utilities

Spacing, sizing, and helper classes.

ClassDescription
n-containerCentered container (max 72rem)
n-mt-{0-4}Margin top (0 / 0.5rem / 1rem / 1.5rem / 2rem)
n-mb-{0-3}Margin bottom
n-p-{0-4}Padding
n-flexFlexbox row with gap
n-grid n-cols-{2-4}CSS Grid with columns
n-text-sm / n-text-lgFont sizes
n-text-mutedMuted text color
n-sr-onlyScreen reader only (visually hidden)
n-hiddenDisplay none
n-rounded / n-rounded-fullBorder radius variants
n-w-fullWidth 100%