Option to opt-out of 'styled' factory in createStyleContext #3429
mahanfakhimi
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Hi team! I propose adding a configuration option (e.g.,
pure: true) to thecreateStyleContexthelper to allow bypassing thepanda()factory and returning standard functional components instead of styled components.Problem Statement/Justification
I've been using the
createStyleContexthelper pattern to bridge recipes with Ark components. Currently, the helper creates components using thepanda()factory function:While this works great for many use cases, it enforces the Styled Component pattern, which introduces a few frictions for strict design systems:
DOM/DevTools Clutter: It wraps pure Ark components in
styledwrappers, making the component tree noisier in React DevTools.Strictness Limitations: In a strict design system, I want to prevent arbitrary style props (like
bg="red") on my components. Even withjsxStyleProps: 'none', wrapping components inpanda()inherently ties them to the styling engine's runtime prop logic.Type Complexity: When dealing with Polymorphism (
asprop) and generics, the current implementation requires complex type gymnastics to satisfy TypeScript, leading toanycasting or cumbersome overrides.Proposed Solution or API
I propose adding a configuration option to
createStyleContext(e.g.,pure: trueoruseStyled: false) that bypasses thepanda()factory entirely.Instead of returning a
styledcomponent, it would return a standard functional component that:className(usingcx) to the underlying component.Proposed API Idea:
Alternatives
I have manually refactored
createStyleContextlocally to remove thepanda()factory dependencies and use rawclassNamemerging. While this works, it diverges from the "standard" helper provided in the docs/snippets, making updates harder.Additional Information
This change would align perfectly with a "Headless" + "Utility-first" philosophy, giving developers full control over the DOM and reducing the abstraction layer for those who prefer a cleaner component tree.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions