Skip to content

Commit 28e9df6

Browse files
committed
fix(checkbox): label gap
- make sure that the label is hidden on first rander if there is no slotted content - move the gap to the base part since label part is no longer added to that element,
1 parent 29d1792 commit 28e9df6

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/components/checkbox/checkbox-base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export class IgcCheckboxBaseComponent extends FormAssociatedCheckboxRequiredMixi
8787

8888
protected override createRenderRoot() {
8989
const root = super.createRenderRoot();
90+
this.hideLabel = isEmpty(this.label);
9091

9192
root.addEventListener('slotchange', () => {
9293
this.hideLabel = isEmpty(this.label);

src/components/checkbox/checkbox.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ export default class IgcCheckboxComponent extends IgcCheckboxBaseComponent {
122122
.hidden=${this.hideLabel}
123123
part=${partNameMap({ label: true, checked })}
124124
id=${this.labelId}
125-
>
126-
<slot></slot>
125+
><slot></slot>
127126
</span>
128127
</label>
129128
${this.renderValidatorContainer()}

src/components/checkbox/themes/checkbox.base.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ $mark-length: 24;
4040
transition: color .2s ease-in-out;
4141
}
4242

43+
[part~='base'] {
44+
gap: rem(8px);
45+
}
46+
4347
[part~='indicator'] {
4448
display: flex;
4549
position: absolute;
@@ -65,7 +69,6 @@ label {
6569
align-items: center;
6670
cursor: pointer;
6771
flex-flow: row nowrap;
68-
gap: rem(8px);
6972
}
7073

7174
[part='indicator checked'] {

0 commit comments

Comments
 (0)