npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

theme-forseen

v0.5.0

Published

A live color theme and font pairing preview drawer for web applications

Downloads

636

Readme

ThemeForseen

Tests

A live color theme and font pairing preview drawer for websites. Browse and preview different color schemes and font combinations in real-time.

ThemeForseen Demo

More details on YouTube.

Features

  • CSS Variables - Sets --color-primary, --font-heading, etc. on <html> for any CSS to consume
  • Live Color Theme Preview - Curated color palettes with instant visual feedback
  • Font Pairing Preview - Thoughtful, beautiful font combinations
  • Light & Dark Mode Support - Separate themes for each mode
  • Dev Server - Write CSS variables directly to your project files with one click
  • Smart Project Detection - Auto-detects Next.js, Vite, Astro, and other frameworks
  • Keyboard Navigation - Arrow keys to browse options
  • Mouse Wheel Support - Scroll through themes and fonts
  • Framework Agnostic - Works with plain CSS, Tailwind, or any CSS framework

Installation

npm install theme-forseen

Setup -- CSS variables

Use these CSS variables in your stylesheets:

--color-primary
--color-primary-shadow
--color-accent
--color-accent-shadow
--color-bg
--color-card-bg
--color-text
--color-extra
--font-heading
--font-body

Setup -- Wiring this up in different systems

CDN On Simple HTML Page

<!DOCTYPE html>
<html>
  <style>
    body {
      color: var(--color-text);
      background: var(--color-bg);
      font-family: var(--font-body);
    }
    h1 {
      color: var(--color-primary);
      font-family: var(--font-heading);
    }
  </style>
  <script type="module" src="https://unpkg.com/theme-forseen"></script>
  <body>
    <h1>Hello World</h1>
    <p>This is my first HTML page.</p>
  </body>
</html>

Tailwind Vite App

  • Create a Vite app:
npm create vite@latest my-app -- --template vanilla
cd my-app
  • Install Tailwind and ThemeForseen:
npm install tailwindcss @tailwindcss/vite theme-forseen
  • Create vite.config.js:
import tailwindcss from "@tailwindcss/vite";
export default { plugins: [tailwindcss()] };
  • Replace index.html:
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>my-app</title>
  </head>
  <body class="bg-bg text-primary">
    <div id="app"></div>
    <script type="module" src="/src/main.js"></script>
  </body>
</html>
  • Replace src/main.js:
import './style.css'
import 'theme-forseen'

document.querySelector('#app').innerHTML = `
<div class="min-h-screen flex items-center justify-center p-8">
  <div class="bg-card-bg rounded-2xl p-8 max-w-md shadow-xl">
    <h1 class="font-heading text-4xl text-primary">Theme Forseen</h1>
    <p class="font-body mt-4 text-text">Preview color themes and font pairings in real-time.</p>
    <div class="mt-6 flex gap-3">
      <button class="bg-primary text-bg px-4 py-2 rounded-lg font-semibold border-2 border-primary-shadow hover:brightness-95 hover:cursor-pointer">Get Started</button>
      <button class="bg-accent text-bg px-4 py-2 rounded-lg font-semibold border-2 border-accent-shadow hover:brightness-95 hover:cursor-pointer">Learn More</button>
    </div>
  </div>
</div>
`
  • Replace src/style.css:
@import "tailwindcss";

@theme inline {
  --color-primary: var(--color-primary);
  --color-primary-shadow: var(--color-primary-shadow);
  --color-accent: var(--color-accent);
  --color-accent-shadow: var(--color-accent-shadow);
  --color-bg: var(--color-bg);
  --color-card-bg: var(--color-card-bg);
  --color-text: var(--color-text);
  --color-extra: var(--color-extra);
  --font-heading: var(--font-heading);
  --font-body: var(--font-body);
}
  • Run the dev server:
npm run dev

Usage

The drawer auto-initializes when you import the module—no setup code needed.

With a Bundler (Vite, Webpack, Parcel, etc.)

<script type="module">
  import "theme-forseen";
</script>

Without a Bundler (plain HTML)

If you're serving static HTML files without a bundler, use the full path:

<script type="module">
  import "/node_modules/theme-forseen/dist/index.js";
</script>

Or use a CDN:

<script type="module">
  import "https://unpkg.com/theme-forseen/dist/index.js";
</script>

SvelteKit

<script>
  import 'theme-forseen';
</script>

React

import "theme-forseen";

function App() {
  return <div>Your app</div>;
}

Styling with CSS Variables

ThemeForseen sets CSS variables on <html> at runtime. Use them in your CSS however you like.

Plain CSS

No config needed. Just use the variables:

h1 {
  color: var(--color-primary);
  font-family: var(--font-heading);
}

body {
  color: var(--color-text);
  background: var(--color-bg);
  font-family: var(--font-body);
}

.card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-accent);
}

Tailwind CSS

To use Tailwind utility classes, map the CSS variables in your config.

Tailwind v4 (CSS-first config)

Add this to your main CSS file:

@import "tailwindcss";

@theme inline {
  --color-primary: var(--color-primary);
  --color-primary-shadow: var(--color-primary-shadow);
  --color-accent: var(--color-accent);
  --color-accent-shadow: var(--color-accent-shadow);
  --color-bg: var(--color-bg);
  --color-card-bg: var(--color-card-bg);
  --color-text: var(--color-text);
  --color-extra: var(--color-extra);
  --font-heading: var(--font-heading);
  --font-body: var(--font-body);
}

The inline keyword tells Tailwind these reference external runtime variables.

Tailwind v3 (JS config)

Update your tailwind.config.js:

export default {
  theme: {
    extend: {
      colors: {
        primary: "var(--color-primary)",
        "primary-shadow": "var(--color-primary-shadow)",
        accent: "var(--color-accent)",
        "accent-shadow": "var(--color-accent-shadow)",
        bg: "var(--color-bg)",
        "card-bg": "var(--color-card-bg)",
        text: "var(--color-text)",
        extra: "var(--color-extra)",
      },
    },
    fontFamily: {
      heading: ["var(--font-heading)", "sans-serif"],
      body: ["var(--font-body)", "sans-serif"],
    },
  },
};

Using Tailwind classes

Then use in your markup:

<h1 class="font-heading text-primary">Hello World</h1>
<p class="font-body text-text bg-bg">Body text</p>

Other CSS Frameworks

Any CSS framework that supports CSS variables will work. Just reference the variables (see CSS Variables Reference below).

How to Use the Drawer

  1. Open: Click the icon on the right side of the screen
  2. Browse Themes: Click to apply, use arrow keys or mouse wheel to scroll
  3. Toggle Mode: Switch between Light and Dark mode
  4. Browse Fonts: Click any font pairing to apply it
  5. Activate: Click the lightning bolt icon to apply the theme to your project (see Dev Server below)

Dev Server

The dev server lets you write CSS variables directly to your project files with one click.

Quick Start

# In your project directory
npx theme-forseen

This starts a local server that listens for theme activations. When you click the lightning bolt icon in the drawer, the CSS variables are written directly to your CSS file.

How It Works

  1. Start the server in your project directory
  2. Browse themes in the drawer as usual
  3. Click the lightning bolt - variables are written to your CSS file instantly
  4. No server running? Falls back to showing a modal with the CSS to copy

Smart Project Detection

The server automatically detects your project type and finds the right CSS file:

| Project Type | CSS File Location | | ------------ | ------------------------------------------ | | Next.js | src/app/globals.css or app/globals.css | | Vite | src/index.css or src/style.css | | Astro | src/styles/global.css | | SvelteKit | src/app.css | | Nuxt | assets/css/main.css | | Plain HTML | Parses index.html for stylesheet links |

Plain HTML Projects

For plain HTML projects, the server is extra smart:

  • One <link rel="stylesheet"> - Writes to that CSS file
  • No stylesheet but has <style> tag - Appends to the inline styles
  • Multiple stylesheets - Uses the first one (or looks for main.css, style.css, etc.)

Generated CSS

The server writes CSS variables in this format:

/* ThemeForseen Colors - Light Mode */
:root {
  --color-primary: #ff3366;
  --color-primary-shadow: #cc2952;
  --color-accent: #ffd600;
  --color-accent-shadow: #ccab00;
  --color-bg: #ffffff;
  --color-card-bg: #fff8f0;
  --color-text: #1a1a1a;
  --color-extra: #ff6b00;
}
/* End ThemeForseen */

Subsequent activations update the existing block without duplicating.

Server Options

npx theme-forseen          # Start the server
npx theme-forseen --help   # Show help
npx theme-forseen -v       # Show version

The server runs on port 3847 by default.

CSS Variables Reference

Colors

| Variable | Description | | ---------------------------------------- | ---------------------------------- | | --color-primary | Primary brand color | | --color-primary-shadow | Darker shade of primary | | --color-accent | Accent/secondary color | | --color-accent-shadow | Darker shade of accent | | --color-bg | Background color | | --color-card-bg | Card/surface background | | --color-text | Main text color | | --color-extra | Additional accent color | | --color-h1, --color-h2, --color-h3 | Heading colors | | --color-heading | General heading color (same as h1) | | --primary-color | Alias for --color-primary | | --secondary-color | Alias for --color-accent |

Fonts

| Variable | Description | | ---------------- | -------------------------- | | --font-heading | Font family for headings | | --font-body | Font family for body text | | --heading-font | Alias for --font-heading | | --body-font | Alias for --font-body |

Customization

Add your own themes by editing src/themes.ts:

export const colorThemes: ColorTheme[] = [
  {
    name: "My Custom Theme",
    light: {
      primary: "#FF0000",
      primaryShadow: "#CC0000",
      accent: "#00FF00",
      accentShadow: "#00CC00",
      background: "#FFFFFF",
      cardBackground: "#F5F5F5",
      text: "#333333",
      extra: "#0000FF",
      h1Color: "primary",
      h2Color: "primary",
      h3Color: "accent",
    },
    dark: {
      // dark mode colors...
    },
  },
];

Rebuild after changes:

npm run build

Development

# Install and build
npm install
npm run build

# Watch mode
npm run dev

Local Testing

To test the drawer locally:

npx serve . -l 3000

Then open http://localhost:3000/tests/fixtures

Running Tests

npm test           # Run all tests
npm run test:ui    # Run with Playwright UI
npm run test:headed # Run in headed browser

Contributing

Contributions welcome!

  1. Fork the repo
  2. Create a feature branch
  3. Make your changes
  4. Open a PR to main

PRs require all tests to pass before merging. Tests run automatically when you open a PR.

How It Works

ThemeForseen sets CSS custom properties (CSS variables) on <html> when you select themes. Your CSS references these variables, so colors and fonts update instantly. Works with plain CSS, Tailwind, or any CSS framework.

Built as a vanilla Web Component, so it works with any framework (React, Vue, Svelte, Astro, plain HTML, etc.).

License

MIT