Material-ui: [RadioButton] Add sub component in label

Created on 25 Jan 2018  路  1Comment  路  Source: mui-org/material-ui


So. I want to add a button on the label of RadioButton.
For example, 'remove the option' button.

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior


Expecting to be able to add MORE THAN JUST TEXT in the label of a radio...

Current Behavior


Currently I replace the RadioButton with just a div, and cant add component inside the label.
Getting this message:

input is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`

Steps to Reproduce (for bugs)

  1. create RadioButtonGroup
  2. create RadioButton inside it
  3. add RaisedButton to the label of the RadioButton.
  4. See '[object Object]' instead of the actual results.

Context

Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | 0.18.5 |
| React | 15.6.1 |
| browser | Google Chrome 63.0.3239.132 |
| etc | |

v0.x

Most helpful comment

OK found how to do that.

Just wrap the content of the label with span and on the button make zIndex of higher magnitude than the radio button.

For example:

    <RadioButton 
    value='option-1'
    label={<span>Option 1 <FlatButton label={this.context.t("Remove")} onTouchTap={() => this.removeOption('option-1')}  style={{zIndex: '999'}}/></span>}  
    />

>All comments

OK found how to do that.

Just wrap the content of the label with span and on the button make zIndex of higher magnitude than the radio button.

For example:

    <RadioButton 
    value='option-1'
    label={<span>Option 1 <FlatButton label={this.context.t("Remove")} onTouchTap={() => this.removeOption('option-1')}  style={{zIndex: '999'}}/></span>}  
    />
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bessonov picture Bessonov  路  93Comments

HZooly picture HZooly  路  63Comments

cfilipov picture cfilipov  路  55Comments

illogikal picture illogikal  路  75Comments

iceafish picture iceafish  路  62Comments