Skip to content

Commit

Permalink
Allow toggle-like switches in RadioItems component
Browse files Browse the repository at this point in the history
  • Loading branch information
tcbegley committed Jul 25, 2019
1 parent bd669bd commit 662aa6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/input/Checklist.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ Checklist.propTypes = {
inline: PropTypes.bool,

/**
* Set to True to render toggle-like switches instead of checkboxes.
* Set to True to render toggle-like switches instead of checkboxes. Ignored
* if custom=False
*/
switch: PropTypes.bool,

Expand Down
9 changes: 8 additions & 1 deletion src/components/input/RadioItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class RadioItems extends React.Component {
key,
value,
custom,
switch: switches,
loading_state
} = this.props;

Expand All @@ -51,7 +52,7 @@ class RadioItems extends React.Component {
checked={checked}
className={inputClassName}
disabled={Boolean(option.disabled)}
type="radio"
type={switches ? 'switch' : 'radio'}
label={option.label}
labelStyle={mergedLabelStyle}
labelClassName={classNames(
Expand Down Expand Up @@ -224,6 +225,12 @@ RadioItems.propTypes = {
*/
inline: PropTypes.bool,

/**
* Set to True to render toggle-like switches instead of radios. Ignored if
* custom=False
*/
switch: PropTypes.bool,

/**
* RadioItems uses custom radio buttons by default. To use native radios set
* custom to False.
Expand Down

0 comments on commit 662aa6f

Please sign in to comment.