Description
Uniwind currently provides the withUniwind HOC to enable styling for third-party components, which works well. However, it introduces some friction when used repeatedly across an app, especially when dealing with many external components.
I’d like to propose adding a generic styled component (e.g. Box) that can style any component, including third-party ones, while preserving proper type inference.
Current Approach
Today, styling third-party components requires explicitly wrapping each component with withUniwind:
https://gist.github.com/divineniiquaye/3d7fe856842d121e2375d0c93d56b4d5
import { withUniwind } from 'uniwind'
import { SafeAreaView } from 'react-native-safe-area-context'
const StyledSafeAreaView = withUniwind(SafeAreaView)
<StyledSafeAreaView className="flex-1 bg-background">
{/* content */}
</StyledSafeAreaView>
This works, but it:
- Adds boilerplate
- Requires creating new wrapped components
- Doesn’t scale ergonomically when many third-party components are involved
Proposed API
Introduce a generic styled component such as Box that internally uses withUniwind and can render any component via an as prop:
import { Box } from 'uniwind'
import { SafeAreaView } from 'react-native-safe-area-context';
<Box
as={SafeAreaView}
className="flex-1 bg-background"
>
{/* content */}
</Box>
Key Expectations
- Box should accept any React component (including third-party ones)
- Props should be properly inferred based on the as component
- className support should work identically to native Uniwind components
- Internally, Box can leverage withUniwind to avoid duplication
Thanks for the great work on Uniwind — this feature would make third-party integration even smoother 🚀
Description
Uniwind currently provides the withUniwind HOC to enable styling for third-party components, which works well. However, it introduces some friction when used repeatedly across an app, especially when dealing with many external components.
I’d like to propose adding a generic styled component (e.g. Box) that can style any component, including third-party ones, while preserving proper type inference.
Current Approach
Today, styling third-party components requires explicitly wrapping each component with withUniwind:
https://gist.github.com/divineniiquaye/3d7fe856842d121e2375d0c93d56b4d5
This works, but it:
Proposed API
Introduce a generic styled component such as Box that internally uses withUniwind and can render any component via an as prop:
Key Expectations
Thanks for the great work on Uniwind — this feature would make third-party integration even smoother 🚀