Skip to content

refactor(theme): move CSS custom property defaults to :root - #357

Merged
ankit-thesys merged 5 commits into
thesysdev:mainfrom
ankit-thesys:feature/Theme-resilance
Mar 20, 2026
Merged

refactor(theme): move CSS custom property defaults to :root#357
ankit-thesys merged 5 commits into
thesysdev:mainfrom
ankit-thesys:feature/Theme-resilance

Conversation

@ankit-thesys

@ankit-thesys ankit-thesys commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Move all --openui-* CSS custom property defaults from inline var() fallbacks to a single :root block in a new auto-generated openui-defaults.scss
  • Simplify cssUtils.scss variables to bare var(--openui-*) without fallbacks
  • Include :root defaults in the bundled components.css via @use in index.scss
  • Export ./defaults.css for consumers using individual component CSS imports

Motivation

Previously every var() call in compiled CSS carried an inline fallback value, duplicated across all 50+ component stylesheets. This change:

  • Produces cleaner, smaller compiled CSS
  • Establishes a single source of truth for default token values
  • Follows the standard CSS custom property pattern (:root defaults, scoped overrides)
  • ThemeProvider continues to override at body/scoped selectors which naturally cascade over :root

Files changed

File Change
src/scripts/generate-css-utils.ts Generates both cssUtils.scss (no fallbacks) and openui-defaults.scss (:root block)
src/cssUtils.scss (auto-generated) Simplified var() calls
src/openui-defaults.scss NEW (auto-generated) :root { --openui-*: defaults }
src/components/index.scss @use "../openui-defaults.scss" at top
src/scripts/scss-import.js Prepends defaults @use when regenerating
cp-css.js Copies openui-defaults.css to dist/styles/
package.json Added ./defaults.css export

Test plan

  • pnpm --filter @openuidev/react-ui build succeeds
  • dist/openui-defaults.css contains :root { --openui-*: ... }
  • dist/components/index.css starts with :root block
  • Individual component CSS uses bare var() without fallbacks
  • dist/styles/openui-defaults.css exists and is importable
  • Storybook renders correctly (ThemeProvider injects all vars at runtime)

🤖 Generated with Claude Code

ankit-thesys and others added 2 commits March 19, 2026 18:13
Instead of embedding fallback values in every var() call across all
component SCSS files, define all --openui-* defaults once in a :root
block via a new auto-generated openui-defaults.scss. This produces
cleaner compiled CSS, a single source of truth for defaults, and
follows the standard CSS custom property pattern where ThemeProvider
overrides at body/scoped selectors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ankit-thesys
ankit-thesys requested a review from abhithesys March 19, 2026 13:53
@ankit-thesys ankit-thesys self-assigned this Mar 19, 2026
@ankit-thesys
ankit-thesys merged commit f03f6df into thesysdev:main Mar 20, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants