[Badge] Typescript Custom Variant does not work
See original GitHub issue- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Expected Behavior 🤔
Typescript should not throw error
Steps to Reproduce 🕹
https://codesandbox.io/s/ecstatic-jackson-i6z4j?file=/src/App.tsx
Your Environment 🌎
`npx @material-ui/envinfo`
System:
OS: macOS 10.15.6
Binaries:
Node: 14.7.0 - /var/folders/7w/t3q6v18575b1rncctdm639040000gn/T/fnm-shell-7427853/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.7 - /var/folders/7w/t3q6v18575b1rncctdm639040000gn/T/fnm-shell-7427853/bin/npm
Browsers:
Chrome: 87.0.4280.141
Edge: Not Found
Firefox: 84.0.1
Safari: 14.0
npmPackages:
@emotion/react: 11.1.4 => 11.1.4
@emotion/styled: 11.0.0 => 11.0.0
@material-ui/core: v5.0.0-alpha.22 => 5.0.0-alpha.22
@material-ui/icons: v5.0.0-alpha.22 => 5.0.0-alpha.22
@material-ui/lab: v5.0.0-alpha.22 => 5.0.0-alpha.22
@material-ui/styled-engine: 5.0.0-alpha.22
@material-ui/styles: 5.0.0-alpha.22
@material-ui/system: 5.0.0-alpha.22
@material-ui/types: 5.1.4
@material-ui/unstyled: 5.0.0-alpha.22
@material-ui/utils: 5.0.0-alpha.22
@types/react: 17.0.0 => 17.0.0
react: 17.0.1 => 17.0.1
react-dom: 17.0.1 => 17.0.1
typescript: 4.1.3 => 4.1.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
[Badge] Typescript Custom Variant does not work · Issue #24323
The problem is that the unstyled component defines the variant as a union of strings, not as overridable string union. I believe we...
Read more >How to use Material UI custom variants in React with Typescript
To extend Typography variant s you can do so: import React from "react"; import { Typography, TypographyProps, createTheme, ThemeOptions, ...
Read more >Advanced Theming - Chakra UI
When defining the styles for the sizes or variants , you can either pass a style object or a function that returns a...
Read more >How to create Badges in Material-UI React - WebDevAssist
Show a dot in the badge: We have another variant for the badge. It is called dot. You can use variant props to...
Read more >Theming · React Native Paper
The neutral variant key color is used to derive medium emphasis text and icons ... If you don't use a custom theme, Paper...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mnajdova Did you consider this solution?
On a broader note:
I second this, that is why I mentioned it. For the
Badge
component, thedot
vsstandard
variant affects the rendered tree of the component itself (whether it will show the content or not for example) - it is not strictly a styling matter. On the other hand, havingBadge
component without this behavior, seems a bit odd, even unstyled Badge, as this seems to be what most of the badge components on the web behave like, that is why I am not sure whether we should strip things like this form the unstyled version. Maybe the problem is that this is part of the variant’s logic, if it was any other prop, like a directdot
boolean prop, I wouldn’t have doubts and would leave it in the unstyled component, as it somehow affects the business logic of the component.