Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't new create inputs variants #28671

Open
1 of 2 tasks
jesusrodrz opened this issue Sep 28, 2021 · 2 comments
Open
1 of 2 tasks

Can't new create inputs variants #28671

jesusrodrz opened this issue Sep 28, 2021 · 2 comments
Labels
component: text field This is the name of the generic UI component, not the React module! new feature New feature or request

Comments

@jesusrodrz
Copy link

I am trying to create a new varian for inputs like I did for buttons
image

When i try to replicate this with MuiIpunt or MuiInputBase the typescript compilert complains like this feature isn't available

image
image

I'm working with the last Mui 5 release

  • 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 🤔

Steps to Reproduce 🕹

Steps:

Context 🔦

Your Environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@jesusrodrz jesusrodrz added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 28, 2021
@siriwatknp siriwatknp added component: text field This is the name of the generic UI component, not the React module! new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 29, 2021
@siriwatknp
Copy link
Member

siriwatknp commented Sep 29, 2021

Unfortunately, it is not possible at this point for TextField related components (Input, InputBase, ...) because variant used in these components contain logic binding eg. label shrink, etc. By allowing more variant, it could break the component.

To achieve the similar result, you can create a new component instead.

import { styled } from '@mui/material/styles';
import InputBase from '@mui/material/InputBase';

const YourInput = styled(InputBase)(({ theme }) => ({
  // ...styling depends on your use case
}))

@GonzAVic
Copy link

I had the same problem, I wanted to create a variant for TextFields but material ui does't support it for this components... here is a workaround I use for this:

https://medium.com/@victorgonz96/create-material-ui-textfield-variants-2616b673cce0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants