Skip to content

Commit 3bc976b

Browse files
feat(toggle): add required prop
1 parent 3f24a12 commit 3bc976b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/src/components/toggle/toggle.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ export class Toggle implements ComponentInterface {
108108
*/
109109
@Prop() alignment?: 'start' | 'center';
110110

111+
/**
112+
* If `true`, the user must fill in a value before submitting a form.
113+
*/
114+
@Prop() required = false;
115+
111116
/**
112117
* Emitted when the user switches the toggle on or off.
113118
*
@@ -290,7 +295,7 @@ export class Toggle implements ComponentInterface {
290295
}
291296

292297
render() {
293-
const { activated, color, checked, disabled, el, justify, labelPlacement, inputId, name, alignment } = this;
298+
const { activated, color, checked, disabled, el, justify, labelPlacement, inputId, name, alignment, required } = this;
294299

295300
const mode = getIonMode(this);
296301
const value = this.getValue();
@@ -327,6 +332,7 @@ export class Toggle implements ComponentInterface {
327332
onFocus={() => this.onFocus()}
328333
onBlur={() => this.onBlur()}
329334
ref={(focusEl) => (this.focusEl = focusEl)}
335+
required={required}
330336
{...this.inheritedAttributes}
331337
/>
332338
<div

0 commit comments

Comments
 (0)