Skip to content

Commit 4e1db70

Browse files
author
Vikas Agarwal
committed
Horizontal checkbox group support
1 parent 4d0a8b8 commit 4e1db70

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

components/Formsy/CheckboxGroup.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CheckboxGroup extends Component {
2121
}
2222

2323
render() {
24-
const { label, name, options } = this.props
24+
const { label, name, options, layout } = this.props
2525
const hasError = !this.props.isPristine() && !this.props.isValid()
2626
const disabled = this.props.isFormDisabled() || this.props.disabled
2727
const errorMessage = this.props.getErrorMessage() || this.props.validationError
@@ -51,9 +51,12 @@ class CheckboxGroup extends Component {
5151
</div>
5252
)
5353
}
54-
54+
const chkGrpClass = cn('checkbox-group', {
55+
horizontal: layout === 'horizontal',
56+
vertical: layout === 'vertical'
57+
})
5558
return (
56-
<div>
59+
<div className={chkGrpClass}>
5760
<label className="checkbox-group-label">{label}</label>
5861
<div className="checkbox-group-options">{options.map(renderOption)}</div>
5962
{ hasError ? (<p className="error-message">{errorMessage}</p>) : null}

components/Formsy/FormFields.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@
111111
}
112112
}
113113
}
114+
115+
.checkbox-group {
116+
display: flex;
117+
}
118+
.checkbox-group.horizontal .checkbox-group-options {
119+
flex-direction: row;
120+
}
121+
.checkbox-group.vertical .checkbox-group-options {
122+
flex-direction: column;
123+
}
114124

115125
.checkbox-group-item {
116126
display: inline-block;

0 commit comments

Comments
 (0)