diff --git a/packages/main/cypress/specs/CheckBox.cy.tsx b/packages/main/cypress/specs/CheckBox.cy.tsx
index c8db82a08613..f1ed8e96ee4d 100644
--- a/packages/main/cypress/specs/CheckBox.cy.tsx
+++ b/packages/main/cypress/specs/CheckBox.cy.tsx
@@ -367,6 +367,75 @@ describe("CheckBox general interaction", () => {
.find("ui5-icon")
.should("have.attr", "name", "tri-state");
});
+
+ it("tests font-size based scaling for standalone checkboxes", () => {
+ cy.mount(
+
+
+
+
+
+ );
+
+ let smallInnerWidth: number;
+ let smallInnerHeight: number;
+ let largeInnerWidth: number;
+ let largeInnerHeight: number;
+ let smallIconWidth: number;
+ let smallIconHeight: number;
+ let largeIconWidth: number;
+ let largeIconHeight: number;
+
+ // Measure small checkbox (12px)
+ cy.get("[ui5-checkbox]").eq(0)
+ .shadow()
+ .find(".ui5-checkbox-inner")
+ .then($inner => {
+ smallInnerWidth = $inner[0].offsetWidth;
+ smallInnerHeight = $inner[0].offsetHeight;
+ });
+
+ cy.get("[ui5-checkbox]").eq(0)
+ .shadow()
+ .find(".ui5-checkbox-icon")
+ .then($icon => {
+ smallIconWidth = $icon[0].offsetWidth;
+ smallIconHeight = $icon[0].offsetHeight;
+ });
+
+ // Measure large checkbox (48px)
+ cy.get("[ui5-checkbox]").eq(1)
+ .shadow()
+ .find(".ui5-checkbox-inner")
+ .then($inner => {
+ largeInnerWidth = $inner[0].offsetWidth;
+ largeInnerHeight = $inner[0].offsetHeight;
+ });
+
+ cy.get("[ui5-checkbox]").eq(1)
+ .shadow()
+ .find(".ui5-checkbox-icon")
+ .then($icon => {
+ largeIconWidth = $icon[0].offsetWidth;
+ largeIconHeight = $icon[0].offsetHeight;
+
+ // Perform assertions after all measurements are captured
+ // 48px checkbox should be ~4x larger than 12px checkbox
+ expect(largeInnerWidth).to.be.closeTo(smallInnerWidth * 4, 2);
+ expect(largeInnerHeight).to.be.closeTo(smallInnerHeight * 4, 2);
+ expect(largeIconWidth).to.be.closeTo(smallIconWidth * 4, 2);
+ expect(largeIconHeight).to.be.closeTo(smallIconHeight * 4, 2);
+ });
+
+ // Verify indeterminate state (tri-state box) scales as well
+ cy.get("[ui5-checkbox]").eq(2)
+ .shadow()
+ .find(".ui5-checkbox-inner")
+ .then($inner => {
+ expect($inner[0].offsetWidth).to.be.greaterThan(smallInnerWidth * 3);
+ expect($inner[0].offsetHeight).to.be.greaterThan(smallInnerHeight * 3);
+ });
+ });
});
describe("Accessibility", () => {
diff --git a/packages/main/src/themes/CheckBox.css b/packages/main/src/themes/CheckBox.css
index 17a8b03cdba0..9b11202deeb7 100644
--- a/packages/main/src/themes/CheckBox.css
+++ b/packages/main/src/themes/CheckBox.css
@@ -6,6 +6,18 @@
display: inline-block;
}
+:host(:not([text])) {
+ font-size: 1.375rem;
+ padding: var(--_ui5_checkbox_wrapper_padding);
+ width: fit-content;
+ height: fit-content;
+ overflow: visible;
+ line-height: 0;
+ --_ui5_checkbox_inner_width_height: 1em;
+ --_ui5_checkbox_icon_size: 1em;
+ --_ui5_checkbox_partially_icon_size: .55em;
+}
+
:host([required]) {
vertical-align: middle;
}
@@ -121,15 +133,23 @@
display: inline-flex;
align-items: center;
max-width: 100%;
- min-height: var(--_ui5_checkbox_width_height);
- min-width: var(--_ui5_checkbox_width_height);
- padding: 0 var(--_ui5_checkbox_wrapper_padding);
box-sizing: border-box;
outline: none;
transition: var(--_ui5_checkbox_transition);
border: var(--_ui5_checkbox_default_focus_border);
border-radius: var(--_ui5_checkbox_border_radius);
- box-sizing: border-box;
+}
+
+:host(:not([text])) .ui5-checkbox-root {
+ width: 1em;
+ height: 1em;
+ padding: 0;
+}
+
+:host([text]) .ui5-checkbox-root {
+ min-height: var(--_ui5_checkbox_width_height);
+ min-width: var(--_ui5_checkbox_width_height);
+ padding: 0 var(--_ui5_checkbox_wrapper_padding);
}
/* focused */
@@ -144,6 +164,13 @@
border-radius: var(--_ui5_checkbox_focus_border_radius);
}
+:host(:not([text])[desktop]) .ui5-checkbox-root:focus::before,
+:host(:not([text])) .ui5-checkbox-root:focus-visible::before {
+ /* Fixed focus outline gap (proportional to text checkbox focus position): -0.425rem / 0.3125rem ≈ -1.36 */
+ inset-inline: calc(var(--_ui5_checkbox_focus_position) * -1.36);
+ inset-block: calc(var(--_ui5_checkbox_focus_position) * -1.36);
+}
+
:host([text]) .ui5-checkbox-root {
padding-inline-end: var(--_ui5_checkbox_right_focus_distance);
}
@@ -250,11 +277,22 @@
transform: translate(-50%, -50%);
}
+:host(:not([text])) .ui5-checkbox-icon {
+ width: 0.75em;
+ height: 0.75em;
+}
+
/* Display only mode */
:host([display-only]) {
cursor: default;
}
+:host([display-only]:not([text])) {
+ font-size: 1rem;
+ width: 1em;
+ height: 1em;
+}
+
:host([display-only]) .ui5-checkbox-display-only-icon-inner [ui5-icon] {
color: var(--sapTextColor);
}
@@ -268,3 +306,8 @@
align-items: center;
justify-content: center;
}
+
+:host([display-only]:not([text])) .ui5-checkbox-display-only-icon-inner [ui5-icon] {
+ width: 1em;
+ height: 1em;
+}
diff --git a/packages/main/test/pages/CheckBox.html b/packages/main/test/pages/CheckBox.html
index 4a4fb9f660b9..55fcdd15d564 100644
--- a/packages/main/test/pages/CheckBox.html
+++ b/packages/main/test/pages/CheckBox.html
@@ -106,6 +106,38 @@
+
+ Font-size based scaling (standalone checkboxes only)
+
+
+
+
+
+
+
+
+
+
+
+ Font-size scaling with display-only
+
+
+
+
+
+
+
+
+ Font-size scaling with padding: 0
+
+
+
+
+
+
+
+
+