Replies: 2 comments
-
there was a discussion related on panda's discord, here's the thread content: MaveriX89 — 07/13/2023 4:52 AM I’m using SolidJS in my case and with the current API, I have to supply my “as” component as the argument to get back a StyledComponent version that can receive all the JSX style props I just need to process all the CSS related things beforehand and supply my “as” to the component prop of <Dynamic component={props.as} {…asCompHTMLProps} {…processedCSSProps} /> Any guidance/help will be greatly appreciated because I want to make sure I account for everything that’s happening inside of factory.js freddie — 07/13/2023 11:08 AM katabsi - Ivica Batinić — 07/13/2023 11:53 AM export const Text = panda(poly('p'), {
base: {},
variants: {}
});
<Text as="span" /> as is not something panda should take care of. It's the React concept and it doesn't apply well to other frameworks (panda is framework agnostic) freddie — 07/13/2023 11:59 AM katabsi - Ivica Batinić — 07/13/2023 12:00 PM freddie — 07/13/2023 12:01 PM here’s a working example: import { Box } from "styled-system/jsx";
import { polymorphicFactory } from "@polymorphic-factory/react";
const poly = polymorphicFactory();
const Text = poly(Box);
const = <Text as="a" href="/" /> If you'd want to control the default tag it becomes slightly more complex: import { polymorphicFactory } from "@polymorphic-factory/react";
import { BoxProps, styled } from "styled-system/jsx";
const poly = polymorphicFactory<BoxProps>({
styled: (component) => (props) => {
const Component = styled(props.as || component);
return <Component {...props} />;
},
});
export const Text = poly("p"); katabsi - Ivica Batinić — 07/13/2023 12:42 PM ti would look like this
export const Text = panda(factory('p'), {
base: {},
variants: {}
});
<Text fontSize="2xl" asChild>
<span>Text</span>
</Text> freddie — 07/13/2023 12:43 PM MaveriX89 — 07/14/2023 5:20 AM |
Beta Was this translation helpful? Give feedback.
-
+1 for recommending the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
It would be nice to have an option to define the output tag when rendering the component in JSX as we would do in Chakra.
Given the following example:
The
<Text>
component will always render a<p>
tag. It would be great if we can somehow specify the output tag when rendering the recipe component like so:Problem Statement/Justification
Simplifies custom recipes and would likely allow an
as="section"
option to default recipes.Proposed Solution or API
I haven't looked at the source yet so don't know
Alternatives
No response
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions