mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
94.04k stars 32.32k forks source link

[TypeScript] Support custom variant to TextField #37846

Open sm2017 opened 1 year ago

sm2017 commented 1 year ago

In TypeScript there is no way to add variant to TextField, there is no TextFieldPropsVariantOverrides or BaseTextFieldPropsVariantOverrides

Is there any temporary workaround?

declare module '@mui/material/TextField' {
  interface TextFieldPropsVariantOverrides {
    dashed: true;
  }
}
michaldudak commented 1 year ago

@mnajdova, you're more familiar with this area. Would you mind checking this?

mnajdova commented 1 year ago

The TextField component does not support the dynamic variants, as the structure of the component depends on this prop - for e.g. different input component is rendered based on the variant prop. We are tracking this issue in https://github.com/mui/material-ui/issues/22259, please upvote it.

mnajdova commented 1 year ago

Related to https://github.com/mui/material-ui/issues/37846

Parvin-Gasimli commented 7 months ago

declare module '@mui/material/TextField' { interface TextFieldPropsVariantOverrides { dashed: true; } } this module is depricated

using this example import { TextField, TextFieldProps } from "@mui/material"; interface CustomTextField {} export const CustomTextField: FC<TextFieldProps & CustomTextField> = ({ className, ...props }) => { return <TextField className={clsx(styles.root, className)} {...props} />; };