Skip to content

feat: [WIP] - Remove styled components#12473

Draft
pedrobonamin wants to merge 5 commits intomainfrom
remove-styled-components
Draft

feat: [WIP] - Remove styled components#12473
pedrobonamin wants to merge 5 commits intomainfrom
remove-styled-components

Conversation

@pedrobonamin
Copy link
Copy Markdown
Contributor

Description

What to review

Testing

Notes for release

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
e2e-studio Building Building Preview, Comment Mar 19, 2026 8:11pm
page-building-studio Error Error Mar 19, 2026 8:11pm
test-studio Error Error Mar 19, 2026 8:11pm

Request Review

Migrates ~293 files in packages/sanity/src from styled-components to
@vanilla-extract/css. This removes all `import {styled} from 'styled-components'`
and `import {useTheme} from 'styled-components'` usage from the sanity package.

Migration patterns applied:
- styled(UIComponent) → base component with className prop
- styled.div/span → .css.ts files with style() and && selectors
- getTheme_v2(props.theme) → useTheme_v2() hook
- theme.sanity.* → useTheme_v2() with direct property access
- Dynamic props → createVar() + assignInlineVars()
- createGlobalStyle → globalStyle() in .css.ts files
- Child/descendant selectors → globalStyle() (style() only targets &)
- CSS custom properties (var(--card-*)) preserved as-is

New files: ~289 .css.ts vanilla-extract style files
Deleted files: ~26 .styled.ts/.styled.tsx/.styles.tsx files replaced by .css.ts
Modified files: ~295 component files updated

@sanity/ui continues to use styled-components internally.
useTheme_v2() from @sanity/ui still works because @sanity/ui's
ThemeProvider wraps children in styled-components' ThemeProvider.

Co-authored-by: luke <luke@miriad.systems>
…tion

- Fix 14 files with syntax errors (leftover styled-components code, missing imports)
- Fix forwardedAs → as prop migration across 15+ files
- Fix assignInlineVars type errors (rem(0) returns number, needs String())
- Fix theme v2 API mismatches (color.card.dark → _dark, etc.)
- Fix wrapper component types (className, style, tone props)
- Fix .ts → .tsx renames for files with JSX
- Fix restricted Popover import(use ui-components)
- Fix React hooks dependency arrays
- Auto-fix lint errors (unused imports, duplicate imports, sort)
- Remove leftover styled-components template literals

~150 files changed, typecheck: 0 errors
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.

1 participant