material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

Add variant to TextField

Open sm2017 opened this issue 1 year ago • 4 comments

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;
  }
}

sm2017 avatar Jul 06 '23 14:07 sm2017

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

michaldudak avatar Jul 11 '23 07:07 michaldudak

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 avatar Jul 18 '23 10:07 mnajdova

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

mnajdova avatar Jul 18 '23 10:07 mnajdova

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} />; };

Parvin-Gasimli avatar Apr 29 '24 12:04 Parvin-Gasimli