Sha256: 172486ec695e61fbc2a6476c90cff128a8628e4d9ecf2d52ce006a14492a2b7c

Contents?: true

Size: 502 Bytes

Versions: 11

Compression:

Stored size: 502 Bytes

Contents

import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
  connect() {
    this.button = this.element.querySelector("button");
    this.checkmark = this.button.querySelector("span");
  }

  toggle() {
    if (this.checkmark.classList.contains("hidden")) {
      this.checkmark.classList.remove("hidden");
      this.button.dataset.state = "checked";
    } else {
      this.checkmark.classList.add("hidden");
      this.button.dataset.state = "unchecked";
    }
  }
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shadcn-ui-0.0.15 app/javascript/controllers/ui/checkbox_controller.js
shadcn-ui-0.0.14 app/javascript/controllers/ui/checkbox_controller.js
shadcn-ui-0.0.13 app/javascript/controllers/ui/checkbox_controller.js
shadcn-ui-0.0.12 app/javascript/controllers/ui/checkbox_controller.js
shadcn-ui-0.0.10 app/javascript/controllers/ui/checkbox_controller.js
shadcn-ui-0.0.8 app/javascript/controllers/ui/checkbox_controller.js
shadcn-ui-0.0.5 app/javascript/controllers/ui/checkbox_controller.js
shadcn-ui-0.0.4 app/javascript/controllers/ui/checkbox_controller.js
shadcn-ui-0.0.3 app/javascript/controllers/ui/checkbox_controller.js
shadcn-ui-0.0.2 app/javascript/controllers/ui/checkbox_controller.js
shadcn-ui-0.0.1 app/javascript/controllers/ui/checkbox_controller.js