diff --git a/src/Label.js b/src/Label.js
index b6c5ffe00..902b40de0 100644
--- a/src/Label.js
+++ b/src/Label.js
@@ -93,13 +93,17 @@ const Label = (props) => {
}
});
+ const colFormLabel = size || colClasses.length;
+ const formLabel = !(check || colFormLabel);
+
const classes = mapToCssModules(classNames(
className,
hidden ? 'visually-hidden' : false,
check ? 'form-check-label' : false,
size ? `col-form-label-${size}` : false,
colClasses,
- colClasses.length ? 'col-form-label' : 'form-label'
+ colFormLabel ? 'col-form-label' : false,
+ formLabel ? 'form-label' : false
), cssModule);
return (
diff --git a/src/__tests__/Label.spec.js b/src/__tests__/Label.spec.js
index 4aef120a0..7ef2484f4 100644
--- a/src/__tests__/Label.spec.js
+++ b/src/__tests__/Label.spec.js
@@ -27,12 +27,30 @@ describe('Label', () => {
expect(wrapper.hasClass('col-form-label')).toBe(true);
});
+ it('should not render with "form-label" class when a col is provided', () => {
+ const wrapper = shallow();
+
+ expect(wrapper.hasClass("form-label")).toBe(false);
+ });
+
it('should render with "form-label" class when a col is not provided', () => {
const wrapper = shallow();
expect(wrapper.hasClass('form-label')).toBe(true);
});
+ it('should render with "form-check-label" class when check is specified', () => {
+ const wrapper = shallow();
+
+ expect(wrapper.hasClass("form-check-label")).toBe(true);
+ });
+
+ it('should not render with "form-label" class when check is specified', () => {
+ const wrapper = shallow();
+
+ expect(wrapper.hasClass("form-label")).toBe(false);
+ });
+
it('should pass col size specific classes as Strings', () => {
const wrapper = shallow();