Skip to content

Commit a35c2b6

Browse files
fix(ui5-checkbox): improved required state placement and asterisks behaviour (#11326)
CheckBox is now properly vertically aligned when set to required and referred in an ui5-label. Additionally when there is not associated label, we now append required asterisks to the internal label (text) of the checkbox. Fixes: #10864
1 parent a894216 commit a35c2b6

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/main/src/CheckBox.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ class CheckBox extends UI5Element implements IFormInputElement {
154154

155155
/**
156156
* Defines whether the component is required.
157+
*
158+
* **Note:** We advise against using the text property of the checkbox when there is a
159+
* label associated with it to avoid having two required asterisks.
157160
* @default false
158161
* @public
159162
* @since 1.3.0

packages/main/src/themes/CheckBox.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@
55
display: inline-block;
66
}
77

8+
:host([required]) {
9+
vertical-align: middle;
10+
}
11+
12+
:host([required]) .ui5-checkbox-label:after {
13+
content:"*";
14+
margin-inline-start: .125rem;
15+
color: var(--sapField_RequiredColor);
16+
font-size: var(--sapFontLargeSize);
17+
font-family: var(--sapFontFamily);
18+
font-weight: bold;
19+
}
20+
821
:host {
922
overflow: hidden;
1023
max-width: 100%;

0 commit comments

Comments
 (0)