Open don-esteban opened 6 months ago
I'd like to add that I like the asChild
-Prop on Radix UI Primitives a lot. It solves the same issue, allows the Child to be anything and is more readable imo than passing the Component as a Prop.
I'd like to add that I like the
asChild
-Prop on Radix UI Primitives a lot. It solves the same issue, allows the Child to be anything and is more readable imo than passing the Component as a Prop.
Yes, that‘s nice too. But Material Tailwind uses the as-prop-approach already (Typography for example). Probably they prefer to stick with one pattern.
Hi all,
many libraries offer link buttons. In other words, links
<a>
styled as buttons.Material Tailwind recommends nesting
<Button>
inside<a>
resulting in invalid HTML. So, this should be fixed (removed?) in the docs. This leads to my feature request.We need another aproach. A simple and clean solution could introduce an
as
prop, similar theas
prop in<Typography>
and in other libs/frameworks like Headless UI. We could use it like this<Button as="a" ...>
or with components like this (important for Next.js apps)
<Button as={Link} ...>
The only work around I came up is using the
<Button>
with JavaScript in theonClick
handler androle
link. This works, but can cause accessibility issues in some cases.<Button onClick={() => location.href='my-url'} role="link" ..>
In Next.js we should use the
useRouter
hook for prefetching.Caveats (work around)
See too
In addition, see this issue #448