MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / render

Method render

core/src/components/toggle/toggle.tsx:438–519  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

436 }
437
438 render() {
439 const {
440 activated,
441 alignment,
442 checked,
443 color,
444 disabled,
445 el,
446 hasLabel,
447 inheritedAttributes,
448 inputId,
449 inputLabelId,
450 justify,
451 labelPlacement,
452 name,
453 required,
454 } = this;
455
456 const mode = getIonMode(this);
457 const value = this.getValue();
458 const rtl = isRTL(el) ? 'rtl' : 'ltr';
459 renderHiddenInput(true, el, name, checked ? value : '', disabled);
460
461 return (
462 <Host
463 role="switch"
464 aria-checked={`${checked}`}
465 aria-describedby={this.hintTextId}
466 aria-invalid={this.isInvalid ? 'true' : undefined}
467 onClick={this.onClick}
468 aria-labelledby={hasLabel ? inputLabelId : null}
469 aria-label={inheritedAttributes['aria-label'] || null}
470 aria-disabled={disabled ? 'true' : null}
471 aria-required={required ? 'true' : undefined}
472 tabindex={disabled ? undefined : 0}
473 onKeyDown={this.onKeyDown}
474 onFocus={this.onFocus}
475 onBlur={this.onBlur}
476 class={createColorClasses(color, {
477 [mode]: true,
478 'in-item': hostContext('ion-item', el),
479 'toggle-activated': activated,
480 'toggle-checked': checked,
481 'toggle-disabled': disabled,
482 [`toggle-justify-${justify}`]: justify !== undefined,
483 [`toggle-alignment-${alignment}`]: alignment !== undefined,
484 [`toggle-label-placement-${labelPlacement}`]: true,
485 [`toggle-${rtl}`]: true,
486 })}
487 >
488 <label class="toggle-wrapper" htmlFor={inputId}>
489 {/*
490 The native control must be rendered
491 before the visible label text due to https://bugs.webkit.org/show_bug.cgi?id=251951
492 */}
493 <input
494 type="checkbox"
495 role="switch"

Callers

nothing calls this directly

Calls 8

getValueMethod · 0.95
renderHintTextMethod · 0.95
renderToggleControlMethod · 0.95
getIonModeFunction · 0.90
isRTLFunction · 0.90
renderHiddenInputFunction · 0.90
createColorClassesFunction · 0.90
hostContextFunction · 0.90

Tested by

no test coverage detected