Skip to content

How do I handle Drawer state using JavaScript ? #1652

Answered by saadeghi
mxvsh asked this question in Q&A
Discussion options

You must be logged in to vote

It has a hidden checkbox. You can check/uncheck the checkbox using JS

<div class="drawer">
  <input id="my-drawer" type="checkbox" class="drawer-toggle" /> <!-- 👈👈👈👈 HERE -->
  <div class="drawer-content">
    <!-- Page content here -->
    <label for="my-drawer" class="btn btn-primary drawer-button">Open drawer</label>
  </div> 
  <div class="drawer-side">
    <label for="my-drawer" class="drawer-overlay"></label>
    <ul class="menu p-4 w-80 bg-base-100 text-base-content">
      <!-- Sidebar content here -->
      <li><a>Sidebar Item 1</a></li>
      <li><a>Sidebar Item 2</a></li>
      
    </ul>
  </div>
</div>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@woss
Comment options

Answer selected by saadeghi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants