Modify Checkboxes based on changes


I wanted to create a checkbox which checks all other checkboxes if checked and if the checkbox is unchecked that all other checkboxes also get unchecked.

For example:

Clicking on “all” should be also checking “option1, option2, etc.”. Same if I uncheck.

I tried to use session_states but could not come up with a solution.
Is there a possibility to modify checkboxes?