-
First of all, great library, I like the theming, the tooling, the docs, superb work. I am trying to dig around a bit to get to know it well. One thing that troubles me for now is the TypeScript support for "Pass Through" components (ActionIcon, Button, ...). Whenever the root node of the component is overridable, the component uses I think it has to do with Do you know of this? Do you have any proposed solutions in mind? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hi, thanks for feedback! I guess this should help with these kind of components – https://mantine.dev/core/button/#typescript Usually it's just enough to use first generic argument to get most of the types coverage: <Button<"a">
component="a"
href="https://mantine.dev"
onClick={(event) => event.preventDefault()}
>
Mantine
</Button> In case you need correct types in <Button<"a", HTMLAnchorElement>
component="a"
href="https://mantine.dev"
onClick={(event) => event.preventDefault()}
elementRef={node => console.log(node)}
>
Mantine
</Button> |
Beta Was this translation helpful? Give feedback.
Hi, thanks for feedback!
I guess this should help with these kind of components – https://mantine.dev/core/button/#typescript
Usually it's just enough to use first generic argument to get most of the types coverage:
In case you need correct types in
elementRef
prop – provide additional generic type (by default it will be HTMLButtonElement in this example without second type):