fix(interface): route Switch through local Toggle to fix Tailwind v4 off-color state - #614
Closed
mdcnick wants to merge 1 commit into
Closed
Conversation
…off-color state The @spacedrive/primitives Switch className references `radix-state-checked:bg-accent`, a Radix v0.x / Tailwind v3-era variant that Tailwind v4 silently drops from the generated CSS. Every toggle in the dashboard renders with the unchecked background color even when data-state=checked. This routes the 5 Switch consumers in interface/ through the local interface/src/ui/Toggle.tsx wrapper, which uses the modern `data-[state=checked]:bg-accent` selector that Tailwind v4 actually understands. No call-site changes — aliased as `Toggle as Switch` so the JSX is byte-identical. Verified: `bunx tsc --noEmit` passes; existing call sites use only `checked`, `onCheckedChange`, `disabled`, and `size` props which Toggle fully supports.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
WalkthroughThe interface replaces primitive-library ChangesToggle import migration
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
Author
|
Closing to test the changes end-to-end before re-opening. Will reopen once verified. |
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
Every toggle in the Spacebot dashboard renders with the unchecked background color even when
data-state="checked"is correctly set on the underlying<button>. Visible repro: Settings → Channels → Telegram "Enabled" switch. Also affects the Server API toggle, Agent Cron toggles, Prompt Inspect capture toggle, and every section in the Config editor (coalesce, memory, browser, projects).Root cause
@spacedrive/primitives'Switchships a className containingradix-state-checked:bg-accent— a Radix v0.x / Tailwind v3-era class variant. Spacebot'sinterface/package.jsonpinstailwindcss: ^4.2.2with@tailwindcss/vite: ^4.2.2. Tailwind v4 removed theradix-state-*:variant family in favor ofdata-[state=*]:*attribute selectors, and Radix v1.x (the resolved@radix-ui/react-switch@1.2.6) emitsdata-state="checked"on the element instead of theradix-state-checkedclass. The selector never matches →bg-app-linealways wins.Fix
Routes all 5 Switch consumers in
interface/through the localinterface/src/ui/Toggle.tsxwrapper, which uses the moderndata-[state=checked]:bg-accent data-[state=unchecked]:bg-app-dark-boxselector and is a drop-in replacement (forwards all RadixRootprops via spread, accepts the samesize: "sm" | "md" | "lg"literals). Aliased asToggle as Switchso the JSX call sites are byte-identical — zero call-site diff.This is the consumer-side workaround. The durable fix belongs in the
@spacedrive/primitivespackage — see the companion PR.Verification
bunx tsc --noEmitininterface/passeschecked,onCheckedChange,disabled, andsizeprops are used, all of which Toggle supportsinterface/src/ui/Toggle.tsxis a 59-line wrapper with no new dependenciesNote
This PR fixes toggle state styling issues by routing all Switch imports through a local Toggle wrapper that uses modern Tailwind v4
data-[state=*]:selectors instead of the deprecated Radix v0.xradix-state-*:class variants. The fix affects 5 files (ChannelSettingCard, PromptInspectModal, ConfigSectionEditor, ServerSection, and AgentCron) with zero visible changes to call sites since the wrapper is aliased asToggle as Switch.Written by Tembo for commit 0e1e1b2c. This will update automatically on new commits.