modus-themes-react

modus-themes-react is a cursor rule for Cursor from julianoczkowski/create-trimble-app. It costs 0 tokens per session (3,304 once invoked), scanned A, original, MIT.

A set of React rules for switching between six Modus and Connect visual themes while retaining the selected theme and avoiding rendering mismatches. React is a JavaScript library for building user interfaces.

In plain words
What is it for?
Use it when adding theme selection, saving a user's theme choice, or supporting the listed Modus and Connect themes in a React app.
Why use it?
It gives the application one consistent place to manage themes, including light and dark variants, and keeps the page stable while the saved theme loads.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { useTheme } from "../hooks/useTheme";.

Good fit Use it when adding theme selection, saving a user's theme choice, or supporting the listed Modus and Connect themes in a React app.

Compare 6 cursor rules from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/julianoczkowski/create-trimble-app
agentmods
npx agentmods add rules/julianoczkowski/create-trimble-app/modus-themes-react

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for modus-themes-react

README.md
[![agentmods](https://agentmods.dev/badge/rules/julianoczkowski/create-trimble-app/modus-themes-react.svg)](https://agentmods.dev/rules/julianoczkowski/create-trimble-app/modus-themes-react)
Your own site
<a href="https://agentmods.dev/rules/julianoczkowski/create-trimble-app/modus-themes-react"><img src="https://agentmods.dev/badge/rules/julianoczkowski/create-trimble-app/modus-themes-react.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 3,304 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.03304
Opus 5 $0.00000 $0.01652
Sonnet 5 $0.00000 $0.00661
Haiku 4.5 $0.00000 $0.00330

Measured 3d ago against content hash 4fcd1aed8d18, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

modus-themes-react scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

templates/react/.cursor/rules/modus-themes-react.mdc · 507 lines

How it starts

The opening of the file, as written. The whole thing — 507 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Modus Themes Implementation in React + Vite

🎨 Theme System Overview

CRITICAL: This React + Vite application supports 6 Modus themes with proper theme switching, persistence, and hydration safety.

Available Themes: 4 Modus themes + 2 Connect themes

  • modus-classic-light / modus-classic-dark
  • modus-modern-light / modus-modern-dark
  • connect-light / connect-dark

🏗️ Theme Architecture

ThemeProvider Setup

// ✅ CORRECT: ThemeProvider in App.tsx
import { ThemeProvider } from "./contexts/ThemeContext";

function App() {
  return (
    <ThemeProvider>
      <ModusProvider>
        <Router>
          <div className="min-h-screen flex flex-col">
            <AppHeader />
            <div className="flex-1">
              <Routes>{/* Routes */}</Routes>
            </div>
            <AppFooter />
          </div>
        </Router>
      </ModusProvider>
    </ThemeProvider>
  );
}

Theme Context Implementation

// ✅ CORRECT: Theme context with hydration safety
import { useEffect, useState, type ReactNode } from "react";
import { ThemeContext, type Theme } from "./ThemeContextData";

interface ThemeProviderProps {
  children: ReactNode;
}

const VALID_THEMES: Theme[] = [
  "modus-classic-light",
  "modus-classic-dark",
  "modus-modern-light",
  "modus-modern-dark",
  "connect-light",
  "connect-dark",
];

export function ThemeProvider({ children }: ThemeProviderProps) {
  const [theme, setThemeState] = useState<Theme>("modus-classic-light");
  const [mounted, setMounted] = useState(false);

  // Derived state
  const isDark = theme.includes("dark");
  const isModern = theme.includes("modern");

  // Load theme from localStorage on mount
  useEffect(() => {
    if (typeof window !== "undefined") {
      try {
        const savedTheme = window.localStorage.getItem(
          "preferred-theme"
        ) as Theme | null;

        if (savedTheme && VALID_THEMES.includes(savedTheme)) {
          setThemeState(savedTheme);
        }
      } catch (error) {
        console.warn("Unable to read stored theme preference:", error);
      }
    }
    setMounted(true);
  }, []);

  // Apply theme to document when it changes
  useEffect(() => {
    if (!mounted) return;

    const html = document.documentElement;

    // Set theme attribute (official Modus way)
    html.setAttribute("data-theme", theme);

    // Save to localStorage
    if (typeof window !== "undefined") {
      try {
        window.localStorage.setItem("preferred-theme", theme);
      } catch (error) {
        console.warn("Unable to persist theme preference:", error);
      }
    }
  }, [theme, mounted]);

  const setTheme = (newTheme: Theme) => {
    setThemeState(newTheme);
  };

  // Prevent hydration mismatch by not rendering until mounted
  if (!mounted) {
    return <>{children}</>;
  }

  return (
    <ThemeContext.Provider value={{ theme, setTheme, isDark, isModern }}>
      {children}
    </ThemeContext.Provider>
  );
}

Read the full file on GitHub · 507 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 507 lines · 0 tokens per session scan A 4fcd1aed8d18

Subscribe to this mod's changes

modus-themes-react is a cursor rule published in the GitHub repository julianoczkowski/create-trimble-app (3 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,304 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.