Checkbox()

Creates a Material Design checkbox input with label. Supports filled and default styles.

Syntax
Result = MaterialSB::Checkbox(Label.s, Flags = #Checkbox_Default, Parent = #Null)
Parameters
Label.s The label text displayed next to the checkbox.
Flags Optional. Combination of checkbox flags for styling and state.
Parent Optional. Parent element. If #Null, uses the current parent from the stack.
Flags
FlagDescription
#Checkbox_DefaultStandard checkbox style (default)
#Checkbox_FilledFilled checkbox style when checked
#Checkbox_CheckedInitially checked state
#Checkbox_DisabledDisabled state
Return Value

Returns the checkbox input element. Access the checked property to get/set state.

Example
Global termsCheckbox

Procedure SubmitForm()
  Protected isChecked
  !v_ischecked = v_termscheckbox.checked;
  If isChecked
    MaterialSB::Toast("Form submitted!")
  Else
    MaterialSB::Toast("Please accept the terms", 3000, MaterialSB::#Toast_Default, "red")
  EndIf
EndProcedure

Procedure Main(Success)
  If Success
    MaterialSB::Row(MaterialSB::#Grid_Container)
      MaterialSB::Col(12, 6)
        MaterialSB::Card()
          MaterialSB::CardContent()
            MaterialSB::Append(MaterialSB::Header("Preferences", 4))
            
            ; Standard checkbox
            MaterialSB::Checkbox("Receive email notifications")
            
            ; Filled style, pre-checked
            MaterialSB::Checkbox("Enable dark mode", MaterialSB::#Checkbox_Filled | MaterialSB::#Checkbox_Checked)
            
            ; Disabled checkbox
            MaterialSB::Checkbox("Premium feature (upgrade required)", MaterialSB::#Checkbox_Disabled)
            
            ; Terms checkbox
            termsCheckbox = MaterialSB::Checkbox("I accept the terms and conditions", MaterialSB::#Checkbox_Filled)
            
          MaterialSB::CloseCurrentParent()
          MaterialSB::CardAction()
            MaterialSB::Button("Submit", @SubmitForm())
          MaterialSB::CloseCurrentParent()
        MaterialSB::CloseCurrentParent()
      MaterialSB::CloseCurrentParent()
    MaterialSB::CloseCurrentParent()
  EndIf
EndProcedure

MaterialSB::Download(@Main())
See Also

Radio(), Switch(), InputSetCallback()