[HELP] styling of element determined by renderAs
prop
#367
Replies: 3 comments
-
Pass in a custom component to const MyCustomSpan = ({ children }) => <span className="p-0">{children}</span> then pass it to <Tabs>
<Tabs.Tab renderAs={MyCustomSpan} className="has-background-success">
...
</Tabs.Tab>
</Tabs> |
Beta Was this translation helpful? Give feedback.
-
Hey @kennethnym, thanks for the advice and the example. I did something like this, cause I needed to pass the tabClassName and tabContent as props. Would be glad to hear what you think of it. <Tabs.Tab
renderAs={() => {
const Tag = getTag(tabRenderAs || renderAs)
return (
<MyCustomTab
tabId={tabId}
tabClassName={tabClassName}
tabContent={tabContent}
/>
)
}}
/>
</Tabs.Tab> |
Beta Was this translation helpful? Give feedback.
-
Just looking at the snippet, I think it's fine. Although I think you should find a way to avoid inlining functions in a huge JSX tree because IMO that hurts readability. |
Beta Was this translation helpful? Give feedback.
-
Hello again and another question.
The code above will generate the following:
I was wondering if there is a way to style the span element (determined by the
renderAs
prop) based on my needs by adding a prop to the<Tabs.Tab>
component?As you can see the
className='has-background-primary'
styles the<li>
element while I would need a way to achieve this:All the best,
Beta Was this translation helpful? Give feedback.
All reactions