From 00961c6e4bfdf74185540252b226d06d808bf335 Mon Sep 17 00:00:00 2001 From: giuliana Date: Thu, 23 Jan 2025 11:44:36 +0000 Subject: [PATCH] feat(checkbox): add required prop --- core/src/components/checkbox/checkbox.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/components/checkbox/checkbox.tsx b/core/src/components/checkbox/checkbox.tsx index 78206b9fd1..e9771e4f28 100644 --- a/core/src/components/checkbox/checkbox.tsx +++ b/core/src/components/checkbox/checkbox.tsx @@ -98,6 +98,11 @@ export class Checkbox implements ComponentInterface { */ @Prop() alignment?: 'start' | 'center'; + /** + * If `true`, the user must fill in a value before submitting a form. + */ + @Prop() required = false; + /** * Emitted when the checked property has changed as a result of a user action such as a click. * @@ -182,6 +187,7 @@ export class Checkbox implements ComponentInterface { name, value, alignment, + required } = this; const mode = getIonMode(this); const path = getSVGPath(mode, indeterminate); @@ -218,6 +224,7 @@ export class Checkbox implements ComponentInterface { onFocus={() => this.onFocus()} onBlur={() => this.onBlur()} ref={(focusEl) => (this.focusEl = focusEl)} + required={required} {...inheritedAttributes} />