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

[InputLabel] Override classes of inner FormLabel #8080

Closed
slavab89 opened this issue Sep 7, 2017 · 4 comments
Closed

[InputLabel] Override classes of inner FormLabel #8080

slavab89 opened this issue Sep 7, 2017 · 4 comments
Assignees
Labels
component: text field This is the name of the generic UI component, not the React module! new feature New feature or request

Comments

@slavab89
Copy link
Contributor

slavab89 commented Sep 7, 2017

When creating a text field using the different component, it doesnt seem to be possible to control the classes of the FormLabel component that InputLabel creates.

I was trying to override the error class to color it differently

<FormControl error>
  <InputLabel htmlFor="something" classes={{ error: classes.differentError}}>My Label</InputLabel> // Works
  <Input id="something" {...input} classes={{ error: classes.differentError }} /> // error is an unknown class
  <FormHelperText classes={{ error: classes.differentError}}>{errorText}</FormHelperText> // Works
</FormControl>

Material-UI: v1.0.0-beta.8

@oliviertassinari oliviertassinari added the status: waiting for author Issue with insufficient information label Sep 7, 2017
@oliviertassinari
Copy link
Member

Looking at the source code, the actual behavior should be the other way around.

Could you provide a reproduction test case? That would help a lot 👷 .
A live example would be perfect. You can use codesandbox.io or webpackbin.com.
I'm closing. Once you have one, feel free to open a new issue. Thanks!

@marcusjwhelan
Copy link

I also have been confused on how to do styling based on current state. in 0.19 you could but in V1 you cannot set label color based on state anymore.

@slavab89
Copy link
Contributor Author

slavab89 commented Sep 7, 2017

@oliviertassinari Could you please clarify what you meant by "other way around"?
The snippet that i've put is from the doc site, i just added the classes prop
https://codesandbox.io/s/xoqnzyry2q

@oliviertassinari oliviertassinari added component: text field This is the name of the generic UI component, not the React module! new feature New feature or request v1 and removed status: waiting for author Issue with insufficient information labels Sep 7, 2017
@oliviertassinari oliviertassinari self-assigned this Sep 8, 2017
@oliviertassinari
Copy link
Member

The following should do it.

<FormControl error>
  <InputLabel htmlFor="something" FormControlClasses={{ error: classes.differentError}}>My Label</InputLabel>
  <Input id="something" {...input} classes={{ error: classes.differentError }} />
  <FormHelperText classes={{ error: classes.differentError}}>{errorText}</FormHelperText>
</FormControl>

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