@@ -85,28 +85,40 @@ And here's what it looks like to build a [custom select](https://tailwindcss.com
85
85
86
86
{ /* prettier-ignore */ }
87
87
``` html
88
+ <label for =" select" class =" block text-sm/6 font-medium text-gray-900" >Assigned to</label >
88
89
<!-- [!code highlight:2] -->
89
- <el-dropdown class =" relative inline-block text-left" >
90
- <button class =" inline-flex w-full justify-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-xs ring-1 ring-gray-300 ring-inset hover:bg-gray-50" >
91
- Options
92
- <svg viewBox =" 0 0 20 20" fill =" currentColor" aria-hidden =" true" class =" -mr-1 size-5 text-gray-400" >
93
- <path d =" M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule =" evenodd" fill-rule =" evenodd" />
90
+ <el-select id =" select" name =" selected" value =" 4" class =" mt-2 block" >
91
+ <button type =" button" class =" grid w-full cursor-default grid-cols-1 ..." >
92
+ <!-- [!code highlight:2] -->
93
+ <el-selectedcontent ></el-selectedcontent >
94
+ <svg viewBox =" 0 0 16 16" fill =" currentColor" aria-hidden =" true" class =" col-start-1 row-start-1 ..." >
95
+ <!-- ... -->
94
96
</svg >
95
97
</button >
96
98
97
99
<!-- [!code highlight:2] -->
98
- <el-menu anchor =" bottom end" popover class =" w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black/5 transition transition-discrete [--anchor-gap:--spacing(2)] focus:outline-hidden data-closed:scale-95 data-closed:transform data-closed:opacity-0 data-enter:duration-100 data-enter:ease-out data-leave:duration-75 data-leave:ease-in" >
99
- <div class =" py-1" >
100
- <a href =" #" class =" block px-4 py-2 text-sm text-gray-700 focus:bg-gray-100 focus:text-gray-900 focus:outline-hidden" >Account settings</a >
101
- <a href =" #" class =" block px-4 py-2 text-sm text-gray-700 focus:bg-gray-100 focus:text-gray-900 focus:outline-hidden" >Support</a >
102
- <a href =" #" class =" block px-4 py-2 text-sm text-gray-700 focus:bg-gray-100 focus:text-gray-900 focus:outline-hidden" >License</a >
103
- <form action =" #" method =" POST" >
104
- <button type =" submit" class =" block w-full px-4 py-2 text-left text-sm text-gray-700 focus:bg-gray-100 focus:text-gray-900 focus:outline-hidden" >Sign out</button >
105
- </form >
106
- </div >
107
- <!-- [!code highlight:3] -->
108
- </el-menu >
109
- </el-dropdown >
100
+ <el-options anchor =" bottom start" popover class =" max-h-60 w-(--button-width) [--anchor-gap:--spacing(1)] ..." >
101
+ <!-- [!code highlight:2] -->
102
+ <el-option value =" 1" class =" group/option relative block focus:bg-indigo-600 ..." >
103
+ <div class =" flex items-center" >
104
+ <span aria-hidden =" true" class =" inline-block size-2 shrink-0 ..." ></span >
105
+ <span class =" ml-3 block group-aria-selected/option:font-semibold ..." >
106
+ Wade Cooper
107
+ <span class =" sr-only" > is online</span >
108
+ </span >
109
+ </div >
110
+ <span class =" group-not-aria-selected/option:hidden group-focus/option:text-white in-[el-selectedcontent]:hidden ..." >
111
+ <svg viewBox =" 0 0 20 20" fill =" currentColor" data-slot =" icon" aria-hidden =" true" class =" size-5" >
112
+ <!-- ... -->
113
+ </svg >
114
+ </span >
115
+ <!-- [!code highlight:2] -->
116
+ </el-option >
117
+ <!-- ... -->
118
+ <!-- [!code highlight:2] -->
119
+ </el-options >
120
+ <!-- [!code highlight:2] -->
121
+ </el-select >
110
122
```
111
123
112
124
See those custom HTML elements like ` <el-select> ` and ` <el-options> ` ? Those are the secret sauce that make everything work, including automatic ARIA attribute management, focus handling, keyboard support, and more.
0 commit comments