feat: support theme for components not using ThemableMixin - #394
Merged
Conversation
Switch and Breadcrumbs support the `theme` attribute at runtime but do not use ThemableMixin (planned for removal in Vaadin 26), so they lack ThemePropertyMixinClass. The conditional type in createComponent gated the `theme` prop on that mixin, causing a TS error when setting `theme` on these components. Add a `createThemedComponent` helper (and ReactWebComponent / ThemedReactWebComponent types) that always exposes a `theme` prop at the type level; the runtime is identical to createComponent since @lit/react already forwards unknown props to the DOM as attributes. A `themedElements` registry in the generator settings opts specific components into this variant. Closes #393 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
vursen
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #393.
SwitchandBreadcrumbssupport thethemeattribute in their web-component API but do not useThemableMixin(planned for removal in Vaadin 26), so their element classes do not exposeThemePropertyMixinClass. The conditional type increateComponentgates thethemeprop on that mixin:As a result,
<Switch theme="…">/<Breadcrumbs theme="slash">producedProperty 'theme' does not exist …, even though the attribute works at runtime.Solution
createComponent.ts— relaxThemedWebComponentPropstoI extends HTMLElement; addReactWebComponent/ThemedReactWebComponenttypes and acreateThemedComponent()helper that always exposesthemeat the type level. Runtime is identical tocreateComponent(unknown props already flow to the DOM as attributes via@lit/react), so this is a type-only fix.scripts/utils/settings.ts— newthemedElementsregistry (Switch,Breadcrumbs) opting components into the themed variant.scripts/generator.ts— emitscreateThemedComponent+theme?: stringfor registry members; all other ~80 components are unchanged.This decouples theme support from the mixin type and gives a clean migration path: as Vaadin 26 removes
ThemableMixin, components move intothemedElementsinstead of silently losingtheme. The conditional-type path for existing mixin components is untouched.Tests
test/ThemedReactWebComponent.spec.tsxwithSwitch(theme="small") andBreadcrumbs(theme="slash") cases.dev/pages/Switch.tsxanddev/pages/Breadcrumbs.tsxfor manual testing.Verification
npm run validate:types→ passnpm test→ 17 files / 104 tests pass (new spec 3/3)🤖 Generated with Claude Code