@@ -22,6 +22,11 @@ classnames:
2222 modifier :
2323 - class : drawer-open
2424 desc : Forces the drawer to be open
25+ variant :
26+ - class : " is-drawer-open:"
27+ desc : Applies styles when the drawer is open
28+ - class : " is-drawer-close:"
29+ desc : Applies styles when the drawer is closed
2530---
2631
2732<script >
@@ -60,13 +65,13 @@ You can check/uncheck the checkbox using JavaScript or by clicking the `label` t
6065### ~ Drawer
6166
6267<div class =" drawer h-56 rounded overflow-hidden " >
63- <input id =" my-drawer " type =" checkbox " class =" drawer-toggle " />
68+ <input id =" my-drawer-1 " type =" checkbox " class =" drawer-toggle " />
6469 <div class =" flex flex-col items-center justify-center drawer-content " >
65- <label for="my-drawer" class="btn btn-primary drawer-button">Open drawer</label>
70+ <label for="my-drawer-1 " class="btn drawer-button">Open drawer</label>
6671 </div >
6772 <div class =" drawer-side z-1002 " >
68- <label for="my-drawer" aria-label="close sidebar" class="drawer-overlay"></label>
69- <ul class="menu p-4 w-60 md:w-80 min-h-full bg-base-200 text-base-content ">
73+ <label for="my-drawer-1 " aria-label="close sidebar" class="drawer-overlay"></label>
74+ <ul class="menu p-4 w-60 md:w-80 min-h-full bg-base-200">
7075 <li><button>Sidebar Item 1</button></li>
7176 <li><button>Sidebar Item 2</button></li>
7277 </ul>
@@ -75,14 +80,14 @@ You can check/uncheck the checkbox using JavaScript or by clicking the `label` t
7580
7681``` html
7782<div class =" $$drawer" >
78- <input id =" my-drawer" type =" checkbox" class =" $$drawer-toggle" />
83+ <input id =" my-drawer-1 " type =" checkbox" class =" $$drawer-toggle" />
7984 <div class =" $$drawer-content" >
8085 <!-- Page content here -->
81- <label for =" my-drawer" class =" $$btn $$btn-primary $$drawer-button" >Open drawer</label >
86+ <label for =" my-drawer-1 " class =" $$btn $$$$drawer-button" >Open drawer</label >
8287 </div >
8388 <div class =" $$drawer-side" >
84- <label for =" my-drawer" aria-label =" close sidebar" class =" $$drawer-overlay" ></label >
85- <ul class =" $$menu bg-base-200 text-base-content min-h-full w-80 p-4" >
89+ <label for =" my-drawer-1 " aria-label =" close sidebar" class =" $$drawer-overlay" ></label >
90+ <ul class =" $$menu bg-base-200 min-h-full w-80 p-4" >
8691 <!-- Sidebar content here -->
8792 <li ><a >Sidebar Item 1</a ></li >
8893 <li ><a >Sidebar Item 2</a ></li >
@@ -96,11 +101,11 @@ You can check/uncheck the checkbox using JavaScript or by clicking the `label` t
96101#### Change screen size to show/hide menu
97102
98103<div class =" drawer h-56 rounded overflow-hidden " >
99- <input id =" my-drawer-3 " type =" checkbox " class =" drawer-toggle " />
104+ <input id =" my-drawer-2 " type =" checkbox " class =" drawer-toggle " />
100105 <div class =" flex flex-col drawer-content " >
101106 <div class="w-full navbar bg-base-300">
102107 <div class="flex-none lg:hidden">
103- <label for="my-drawer-3 " aria-label="open sidebar" class="btn btn-square btn-ghost">
108+ <label for="my-drawer-2 " aria-label="open sidebar" class="btn btn-square btn-ghost">
104109 <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="inline-block w-6 h-6 stroke-current"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path></svg>
105110 </label>
106111 </div>
@@ -115,7 +120,7 @@ You can check/uncheck the checkbox using JavaScript or by clicking the `label` t
115120 <div class="flex justify-center items-center grow">Content</div>
116121 </div >
117122 <div class =" drawer-side z-1002 " >
118- <label for="my-drawer-3 " aria-label="close sidebar" class="drawer-overlay"></label>
123+ <label for="my-drawer-2 " aria-label="close sidebar" class="drawer-overlay"></label>
119124 <ul class="p-4 menu w-60 md:w-80 min-h-full bg-base-200">
120125 <li><button>Sidebar Item 1</button></li>
121126 <li><button>Sidebar Item 2</button></li>
@@ -125,12 +130,12 @@ You can check/uncheck the checkbox using JavaScript or by clicking the `label` t
125130
126131``` html
127132<div class =" $$drawer" >
128- <input id =" my-drawer-3 " type =" checkbox" class =" $$drawer-toggle" />
133+ <input id =" my-drawer-2 " type =" checkbox" class =" $$drawer-toggle" />
129134 <div class =" $$drawer-content flex flex-col" >
130135 <!-- Navbar -->
131136 <div class =" $$navbar bg-base-300 w-full" >
132137 <div class =" flex-none lg:hidden" >
133- <label for =" my-drawer-3 " aria-label =" open sidebar" class =" $$btn $$btn-square $$btn-ghost" >
138+ <label for =" my-drawer-2 " aria-label =" open sidebar" class =" $$btn $$btn-square $$btn-ghost" >
134139 <svg
135140 xmlns =" http://www.w3.org/2000/svg"
136141 fill =" none"
@@ -159,7 +164,7 @@ You can check/uncheck the checkbox using JavaScript or by clicking the `label` t
159164 Content
160165 </div >
161166 <div class =" $$drawer-side" >
162- <label for =" my-drawer-3 " aria-label =" close sidebar" class =" $$drawer-overlay" ></label >
167+ <label for =" my-drawer-2 " aria-label =" close sidebar" class =" $$drawer-overlay" ></label >
163168 <ul class =" $$menu bg-base-200 min-h-full w-80 p-4" >
164169 <!-- Sidebar content here -->
165170 <li ><a >Sidebar Item 1</a ></li >
@@ -174,13 +179,13 @@ You can check/uncheck the checkbox using JavaScript or by clicking the `label` t
174179#### Sidebar is always visible on large screen, can be toggled on small screen because of lg: drawer-open class
175180
176181<div class =" drawer lg:drawer-open h-56 rounded overflow-hidden " >
177- <input id =" my-drawer-2 " type =" checkbox " class =" drawer-toggle " />
182+ <input id =" my-drawer-3 " type =" checkbox " class =" drawer-toggle " />
178183 <div class =" flex flex-col items-center justify-center drawer-content " >
179- <label for="my-drawer-2 " class="btn btn-primary drawer-button lg:hidden">Open drawer</label>
184+ <label for="my-drawer-3 " class="btn drawer-button lg:hidden">Open drawer</label>
180185 </div >
181186 <div class =" drawer-side max-lg:z-1002 " >
182- <label for="my-drawer-2 " aria-label="close sidebar" class="drawer-overlay"></label>
183- <ul class="menu p-4 w-60 md:w-80 min-h-full bg-base-200 text-base-content ">
187+ <label for="my-drawer-3 " aria-label="close sidebar" class="drawer-overlay"></label>
188+ <ul class="menu p-4 w-60 md:w-80 min-h-full bg-base-200">
184189 <li><button>Sidebar Item 1</button></li>
185190 <li><button>Sidebar Item 2</button></li>
186191 </ul>
@@ -189,16 +194,16 @@ You can check/uncheck the checkbox using JavaScript or by clicking the `label` t
189194
190195``` html
191196<div class =" $$drawer lg:$$drawer-open" >
192- <input id =" my-drawer-2 " type =" checkbox" class =" $$drawer-toggle" />
197+ <input id =" my-drawer-3 " type =" checkbox" class =" $$drawer-toggle" />
193198 <div class =" $$drawer-content flex flex-col items-center justify-center" >
194199 <!-- Page content here -->
195- <label for =" my-drawer-2 " class =" $$btn $$btn-primary $$drawer-button lg:hidden" >
200+ <label for =" my-drawer-3 " class =" $$btn $$$$drawer-button lg:hidden" >
196201 Open drawer
197202 </label >
198203 </div >
199204 <div class =" $$drawer-side" >
200- <label for =" my-drawer-2 " aria-label =" close sidebar" class =" $$drawer-overlay" ></label >
201- <ul class =" $$menu bg-base-200 text-base-content min-h-full w-80 p-4" >
205+ <label for =" my-drawer-3 " aria-label =" close sidebar" class =" $$drawer-overlay" ></label >
206+ <ul class =" $$menu bg-base-200 min-h-full w-80 p-4" >
202207 <!-- Sidebar content here -->
203208 <li ><a >Sidebar Item 1</a ></li >
204209 <li ><a >Sidebar Item 2</a ></li >
@@ -207,16 +212,107 @@ You can check/uncheck the checkbox using JavaScript or by clicking the `label` t
207212</div >
208213```
209214
215+
216+ ### ~ Icon-only drawer when it's closed. Using is-drawer-close and is-drawer-open variants
217+
218+ #### In this example instead of completely hiding the drawer sidebar, we only show the icons when the drawer is closed. To add styles based on the state of the drawer, we use the ` is-drawer-open ` and ` is-drawer-close ` variants. For example ` is-drawer-close:hidden ` or ` is-drawer-open:w-80 ` . Also we have tooltips when the drawer is closed and a switch button to open/close the drawer and rotates the button icon based on the state of the drawer.
219+
220+ <div class =" drawer drawer-open h-56 rounded overflow-hidden " >
221+ <input id =" my-drawer-4 " type =" checkbox " class =" drawer-toggle " />
222+ <div class =" h-56 drawer-content " >
223+ <!-- Page content here -->
224+ </div >
225+ <div class =" drawer-side is-drawer-close:overflow-visible h-full max-lg:z-1002 " >
226+ <label for="my-drawer-4" aria-label="close sidebar" class="drawer-overlay"></label>
227+ <div class="is-drawer-close:w-17 is-drawer-open:w-64 h-full bg-base-200 flex flex-col items-start">
228+ <ul class="menu p-4 w-full grow">
229+ <li>
230+ <button class="is-drawer-close:tooltip is-drawer-close:tooltip-right rtl:is-drawer-close:tooltip-left" data-tip="Homepage">
231+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-linejoin="round" stroke-linecap="round" stroke-width="2" fill="none" stroke="currentColor" class="inline-block size-4 my-1.5">
232+ <path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8"></path>
233+ <path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
234+ </svg>
235+ <span class="is-drawer-close:hidden">Homepage</span>
236+ </button>
237+ </li>
238+ <li>
239+ <button class="is-drawer-close:tooltip is-drawer-close:tooltip-right rtl:is-drawer-close:tooltip-left" data-tip="Settings">
240+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-linejoin="round" stroke-linecap="round" stroke-width="2" fill="none" stroke="currentColor" class="inline-block size-4 my-1.5">>
241+ <path d="M20 7h-9"></path>
242+ <path d="M14 17H5"></path>
243+ <circle cx="17" cy="17" r="3"></circle>
244+ <circle cx="7" cy="7" r="3"></circle>
245+ </svg>
246+ <span class="is-drawer-close:hidden">Settings</span>
247+ </button>
248+ </li>
249+ </ul>
250+ <div class="m-3.5 is-drawer-close:tooltip is-drawer-close:tooltip-right rtl:is-drawer-close:tooltip-left" data-tip="Open">
251+ <label for="my-drawer-4" class="btn btn-ghost btn-circle drawer-button is-drawer-open:rotate-y-180">
252+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-linejoin="round" stroke-linecap="round" stroke-width="2" fill="none" stroke="currentColor" class="inline-block size-4 my-1.5">
253+ <path d="M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"></path>
254+ <path d="M9 4v16"></path>
255+ <path d="M14 10l2 2l-2 2"></path>
256+ </svg>
257+ </label>
258+ </div>
259+ </div>
260+ </div >
261+ </div >
262+
263+ ``` html
264+ <div class =" $$drawer $$drawer-open" >
265+ <input id =" my-drawer-4" type =" checkbox" class =" $$drawer-toggle" />
266+ <div class =" $$drawer-content" >
267+ <!-- Page content here -->
268+ </div >
269+
270+ <div class =" $$drawer-side is-drawer-close:overflow-visible" >
271+ <label for =" my-drawer-4" aria-label =" close sidebar" class =" $$drawer-overlay" ></label >
272+ <div class =" is-drawer-close:w-17 is-drawer-open:w-64 bg-base-200 flex flex-col items-start min-h-full" >
273+ <!-- Sidebar content here -->
274+ <ul class =" $$menu w-full grow p-4" >
275+
276+ <!-- list item -->
277+ <li >
278+ <button class =" is-drawer-close:tooltip is-drawer-close:tooltip-right" data-tip =" Homepage" >
279+ <svg xmlns =" http://www.w3.org/2000/svg" viewBox =" 0 0 24 24" stroke-linejoin =" round" stroke-linecap =" round" stroke-width =" 2" fill =" none" stroke =" currentColor" class =" inline-block size-4 my-1.5" ><path d =" M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" ></path ><path d =" M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" ></path ></svg >
280+ <span class =" is-drawer-close:hidden" >Homepage</span >
281+ </button >
282+ </li >
283+
284+ <!-- list item -->
285+ <li >
286+ <button class =" is-drawer-close:tooltip is-drawer-close:tooltip-right" data-tip =" Settings" >
287+ <svg xmlns =" http://www.w3.org/2000/svg" viewBox =" 0 0 24 24" stroke-linejoin =" round" stroke-linecap =" round" stroke-width =" 2" fill =" none" stroke =" currentColor" class =" inline-block size-4 my-1.5" ><path d =" M20 7h-9" ></path ><path d =" M14 17H5" ></path ><circle cx =" 17" cy =" 17" r =" 3" ></circle ><circle cx =" 7" cy =" 7" r =" 3" ></circle ></svg >
288+ <span class =" is-drawer-close:hidden" >Settings</span >
289+ </button >
290+ </li >
291+ </ul >
292+
293+ <!-- button to open/close drawer -->
294+ <div class =" m-3.5 is-drawer-close:tooltip is-drawer-close:tooltip-right" data-tip =" Open" >
295+ <label for =" my-drawer-4" class =" $$btn $$btn-ghost $$btn-circle $$drawer-button is-drawer-open:rotate-y-180" >
296+ <svg xmlns =" http://www.w3.org/2000/svg" viewBox =" 0 0 24 24" stroke-linejoin =" round" stroke-linecap =" round" stroke-width =" 2" fill =" none" stroke =" currentColor" class =" inline-block size-4 my-1.5" ><path d =" M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z" ></path ><path d =" M9 4v16" ></path ><path d =" M14 10l2 2l-2 2" ></path ></svg >
297+ </label >
298+ </div >
299+
300+ </div >
301+ </div >
302+ </div >
303+ ```
304+
305+
210306### ~ Drawer that opens from right side of page
211307
212308<div class =" drawer drawer-end h-56 rounded overflow-hidden " >
213- <input id =" my-drawer-4 " type =" checkbox " class =" drawer-toggle " />
309+ <input id =" my-drawer-5 " type =" checkbox " class =" drawer-toggle " />
214310 <div class =" flex flex-col items-center justify-center drawer-content " >
215- <label for="my-drawer-4 " class="btn btn-primary drawer-button">Open drawer</label>
311+ <label for="my-drawer-5 " class="btn drawer-button">Open drawer</label>
216312 </div >
217313 <div class =" drawer-side z-1002 " >
218- <label for="my-drawer-4 " aria-label="close sidebar" class="drawer-overlay"></label>
219- <ul class="menu p-4 w-60 md:w-80 min-h-full bg-base-200 text-base-content ">
314+ <label for="my-drawer-5 " aria-label="close sidebar" class="drawer-overlay"></label>
315+ <ul class="menu p-4 w-60 md:w-80 min-h-full bg-base-200">
220316 <li><button>Sidebar Item 1</button></li>
221317 <li><button>Sidebar Item 2</button></li>
222318 </ul>
@@ -225,14 +321,14 @@ You can check/uncheck the checkbox using JavaScript or by clicking the `label` t
225321
226322``` html
227323<div class =" $$drawer $$drawer-end" >
228- <input id =" my-drawer-4 " type =" checkbox" class =" $$drawer-toggle" />
324+ <input id =" my-drawer-5 " type =" checkbox" class =" $$drawer-toggle" />
229325 <div class =" $$drawer-content" >
230326 <!-- Page content here -->
231- <label for =" my-drawer-4 " class =" $$drawer-button $$btn $$btn-primary" >Open drawer</label >
327+ <label for =" my-drawer-5 " class =" $$drawer-button $$btn $$btn-primary" >Open drawer</label >
232328 </div >
233329 <div class =" $$drawer-side" >
234- <label for =" my-drawer-4 " aria-label =" close sidebar" class =" $$drawer-overlay" ></label >
235- <ul class =" $$menu bg-base-200 text-base-content min-h-full w-80 p-4" >
330+ <label for =" my-drawer-5 " aria-label =" close sidebar" class =" $$drawer-overlay" ></label >
331+ <ul class =" $$menu bg-base-200 min-h-full w-80 p-4" >
236332 <!-- Sidebar content here -->
237333 <li ><a >Sidebar Item 1</a ></li >
238334 <li ><a >Sidebar Item 2</a ></li >
0 commit comments