MCPcopy Create free account
hub / github.com/ionic-team/ionic-framework / Checkbox

Class Checkbox

core/src/components/checkbox/checkbox.tsx:33–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 shadow: true,
32})
33export class Checkbox implements ComponentInterface {
34 private inputId = `ion-cb-${checkboxIds++}`;
35 private inputLabelId = `${this.inputId}-lbl`;
36 private helperTextId = `${this.inputId}-helper-text`;
37 private errorTextId = `${this.inputId}-error-text`;
38 private inheritedAttributes: Attributes = {};
39 private validationObserver?: MutationObserver;
40
41 @Element() el!: HTMLIonCheckboxElement;
42
43 /**
44 * The color to use from your application's color palette.
45 * Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
46 * For more information on colors, see [theming](/docs/theming/basics).
47 */
48 @Prop({ reflect: true }) color?: Color;
49
50 /**
51 * The name of the control, which is submitted with the form data.
52 */
53 @Prop() name: string = this.inputId;
54
55 /**
56 * If `true`, the checkbox is selected.
57 */
58 @Prop({ mutable: true }) checked = false;
59
60 /**
61 * If `true`, the checkbox will visually appear as indeterminate.
62 */
63 @Prop({ mutable: true }) indeterminate = false;
64
65 /**
66 * If `true`, the user cannot interact with the checkbox.
67 */
68 @Prop() disabled = false;
69
70 /**
71 * Text that is placed under the checkbox label and displayed when an error is detected.
72 */
73 @Prop() errorText?: string;
74
75 /**
76 * Text that is placed under the checkbox label and displayed when no error is detected.
77 */
78 @Prop() helperText?: string;
79
80 /**
81 * The value of the checkbox does not mean if it's checked or not, use the `checked`
82 * property for that.
83 *
84 * The value of a checkbox is analogous to the value of an `<input type="checkbox">`,
85 * it's only used when the checkbox participates in a native `<form>`.
86 */
87 @Prop() value: any | null = 'on';
88
89 /**
90 * Where to place the label relative to the checkbox.

Callers

nothing calls this directly

Calls 2

toggleCheckedMethod · 0.80
setCheckedMethod · 0.45

Tested by

no test coverage detected