-
Notifications
You must be signed in to change notification settings - Fork 232
Checkbox with label is rendered wrong #929
Comments
@seriema yes, adding the form field component is the correct solution. We never created the form-field component since it is just styles. But if you'd like to create a component for it please feel free :) |
@moog16 Something like this? https://stackblitz.com/edit/mcwr-form-field?file=form-field%2Findex.tsx |
@seriema I see what you mean - it seems to work without those adapter methods. I don't see why we need them as its handled by the checkbox and radio. I think for now we can leave it as you have it. FormField was not designed with React in mind. This component is really more about the styles/scss. PS: I took a look at RMWC. James also doesn't implement the adapter. This leads me to be more confident in my opinion above. |
I just noticed that Radio already wraps itself in 'mdc-form-field'. So either:
Both Radio and Checkbox MCW "Basic Usage" says:
I'd go with nr 1 for solving my original issue, as the issue doesn't exist on Radio. What do you think @moog16? |
I noticed issue #438, where you say the checkbox should be built through composition with a 1ABut it's usually better with composition (as noted in #438) in the long run, so I'd propose this: 1BSwitch is a similar component and currently looks like Checkbox so whatever we choose here should be applied to Switch. Need to keep #308 in mind. Are we aiming for option 1B then @moog16 ? |
#308 is actually pretty easy as we have added it to drawer (see attachRef method). That can be addressed at any time. I believe that all components are better to be used through composition. So switch, radio, checkbox should all be built the same. So it'd be great to have 1B, however I think converting checkbox over is a lot more work than you probably asked for. |
for css -- apparently. (Found this all woefully confusing.) |
Uh oh!
There was an error while loading. Please reload this page.
Issue
According to the readme it's possible to just add a standard
<label>
element after the checkbox.Will render a checkbox looking like this, with the label wrongly positioned and wrong font:

Example code here:
https://stackblitz.com/edit/react-wpvkxv
Possible solution
It's missing the Form Field CSS. There is no Form Field React component so this is the best solution I found but it seems wrong to have to do it like this:
<Checkbox>
and<label>
with the class "mdc-form-field"Then it looks as expected:

Example code here:
https://stackblitz.com/edit/react-stbwsz?file=Checkbox.js
The text was updated successfully, but these errors were encountered: