theme-ui icon indicating copy to clipboard operation
theme-ui copied to clipboard

components: Remove style props

Open lachlanjc opened this issue 1 year ago • 6 comments

We'd mentioned this in #2275 & #832 as part of simplifying our API, as it can lead to confusing CSS ordering & overrides: if I have the same property in a style prop & sx, which wins out? It's especially unclear from a component that's wrapping a Theme UI component. This is a big, breaking change, so it should definitely not be in our MDX release, in case folks don't want to upgrade immediately. Providing a codemod would be great too; I haven't worked on that yet.

Release notes

  • BREAKING: Theme UI Components no longer accept style props (e.g. <Box bg="primary" mt={3}), in favor of only supporting styling through the sx prop.
    • The Field component now accepts a second containerSx prop, intended to replace whitespace style props (e.g. to convert <Field my={3} sx={{ … }} to <Field containerSx={{ my: 3 }} sx={{ … }}). Checkbox, Select, and Switch have this new prop as well.

lachlanjc avatar Sep 22 '22 20:09 lachlanjc

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
theme-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2023 3:50pm

vercel[bot] avatar Sep 22 '22 20:09 vercel[bot]

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 37becf737381e485dcd5b72017f785b1616babb6:

Sandbox Source
next-theme-ui-example Configuration
gatsby-plugin-theme-ui-example Configuration

codesandbox-ci[bot] avatar Sep 22 '22 20:09 codesandbox-ci[bot]

@hasparus thoughts on this?

lachlanjc avatar Nov 15 '22 13:11 lachlanjc

Looks good to me. I very much appreciate the containerSx prop!

devatrox avatar Mar 31 '23 06:03 devatrox

@lachlanjc I can write a simple codemod if you think it's good to merge.

hasparus avatar Mar 31 '23 13:03 hasparus

That'd be amazing! Definitely my main hesitation.

lachlanjc avatar Mar 31 '23 14:03 lachlanjc