From 85cc77124291a70e4315fdeea9983034a0558b3f Mon Sep 17 00:00:00 2001 From: Nikos Douvlis Date: Wed, 4 Mar 2026 15:44:01 +0200 Subject: [PATCH 1/5] feat(ui): add raw mode theme that strips decorative CSS Add a "raw" theme that strips all decorative CSS (colors, shadows, borders, fonts, transitions) from component variants while keeping structural CSS (layout, flex, grid, position, sizing). This gives components a plain-HTML feel as a blank canvas for custom styling via the elements API. Key changes: - stripDecorativeStyles utility with structural property allowlist - rawMode flag propagated through appearance context and theme - createVariants strips variant output in raw mode - makeCustomizable strips defaultStyles and sx (preserving icon content) - Dev mode overlay hidden in raw mode - Sandbox: theme selector, Tailwind toggle, initial theme loading fix --- packages/clerk-js/sandbox/app.ts | 7 +- packages/clerk-js/sandbox/template.html | 1 + .../ui/src/customizables/makeCustomizable.tsx | 24 ++++- .../ui/src/customizables/parseAppearance.ts | 5 +- packages/ui/src/hooks/useDevMode.tsx | 7 +- .../styledSystem/InternalThemeProvider.tsx | 8 +- .../ui/src/styledSystem/createVariants.ts | 4 + .../src/styledSystem/stripDecorativeStyles.ts | 100 ++++++++++++++++++ packages/ui/src/themes/index.ts | 1 + packages/ui/src/themes/raw.ts | 54 ++++++++++ 10 files changed, 199 insertions(+), 12 deletions(-) create mode 100644 packages/ui/src/styledSystem/stripDecorativeStyles.ts create mode 100644 packages/ui/src/themes/raw.ts diff --git a/packages/clerk-js/sandbox/app.ts b/packages/clerk-js/sandbox/app.ts index 3be79d71860..bb6f9adf400 100644 --- a/packages/clerk-js/sandbox/app.ts +++ b/packages/clerk-js/sandbox/app.ts @@ -1,6 +1,6 @@ import { PageMocking, type MockScenario } from '@clerk/msw'; import * as l from '../../localizations'; -import { dark, neobrutalism, shadcn, shadesOfPurple } from '../../ui/src/themes'; +import { dark, neobrutalism, raw, shadcn, shadesOfPurple } from '../../ui/src/themes'; import type { Clerk as ClerkType } from '../'; import * as scenarios from './scenarios'; @@ -319,6 +319,7 @@ const themes: Record = { shadesOfPurple, neobrutalism, shadcn, + raw, }; function themeSelector() { @@ -326,7 +327,7 @@ function themeSelector() { const themeSelect = document.getElementById('themeSelect') as HTMLSelectElement; - const savedTheme = sessionStorage.getItem('baseTheme') ?? ''; + const savedTheme = sessionStorage.getItem('baseTheme') ?? 'raw'; themeSelect.value = savedTheme; const updateTheme = () => { @@ -533,7 +534,7 @@ void (async () => { await mocking.initialize(route, { scenario }); } - const initialThemeName = sessionStorage.getItem('baseTheme') ?? ''; + const initialThemeName = sessionStorage.getItem('baseTheme') ?? 'raw'; const initialTheme = initialThemeName ? themes[initialThemeName] : undefined; const initialPresetName = sessionStorage.getItem('preset') ?? ''; const initialPreset = initialPresetName ? presets[initialPresetName] : undefined; diff --git a/packages/clerk-js/sandbox/template.html b/packages/clerk-js/sandbox/template.html index eb7f557034e..ae342e59d72 100644 --- a/packages/clerk-js/sandbox/template.html +++ b/packages/clerk-js/sandbox/template.html @@ -375,6 +375,7 @@ +