Replies: 1 comment
-
For anyone interested, here is a quick workaround import { Box as Boxy } from '../styled-system/jsx';
import type { BoxProps } from '../styled-system/jsx';
type PolymorphicProps<E extends React.ElementType> = React.PropsWithChildren<
React.ComponentPropsWithoutRef<E> & {
as?: E;
}
> &
BoxProps;
export const Box = <E extends React.ElementType>({
as,
...props
}: PolymorphicProps<E>) => {
return <Boxy {...props} as={as} />;
}; And you can use it as: export const Foo = () => <Box as="a" href="https://google.com">Click me</Box> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
Hi there,
When trying to use the the
Box
component generated along with theas
prop the compiler complains although the output is properly and semantically rendered.Link to Reproduction
https://stackblitz.com/edit/vitejs-vite-3d7r7f?file=src%2FApp.tsx
Steps to reproduce
import { Box } from '../styled-system/jsx';
<Box as="h1>Hey</Box>
Hey
JS Framework
React
Panda CSS Version
0.46.1
Browser
No response
Operating System
Additional Information
Stitches has a really nice API where the
<Box />
also inherits the passed through element's properties which would amazing to have as it can get composed over and over again.styled-system
also follows a similar approach https://github.com/styled-system/styled-systemBeta Was this translation helpful? Give feedback.
All reactions