-
HTMLのselect要素の新たな可能性
Web上で選択メニューのスタイルを自在にコントロールする方法を学びましょう。HTMLのselect要素は、CSSのappearanceの新しい値、および新しい擬似要素によって大幅にアップグレードされます。HTMLの新機能によって、selectのオプションにリッチコンテンツを含める新たな可能性がもたらされます。標準要素のアクセシビリティと堅牢性を維持しながら、デザインシステムに合わせたselect要素を作成する方法を確認します。
関連する章
- 0:00 - Introduction
- 2:32 - Style the select button
- 3:47 - Customize the drop-down
- 5:00 - Go beyond text options
- 6:50 - The selectedcontent element
- 7:46 - Fallback for unsupported browsers
- 8:49 - Next steps
リソース
- WebKit.org - Example website demonstrating Customizable Select
- WebKit.org - CSS Grid Lanes Field Guide
- WebKit.org – Report issues to the WebKit open-source project
- Submit feedback
関連ビデオ
WWDC26
-
このビデオを検索
-
-
1:11 - Basic markup
<label for="sort-select">Sort by</label> <select id="sort-select"> <option>Newest</option> <option>Oldest</option> </select> -
2:37 - Native form control
select { } -
2:50 - appearance: base-select
body { font-family: Gill Sans, sans-serif; } select { appearance: base-select; } -
3:07 - Style the select button
select { appearance: base-select; background-color: var(--green-10); border: none; padding: 0.6em 1em; } -
3:08 - Picker icon
select:open { background-color: var(--green-100); color: white; } -
3:29 - Picker icon open state
select:open { background-color: var(--green-100); color: white; } select:open::picker-icon { content: url(icons/arrow-white.svg); } -
4:08 - Picker select
::picker(select) { } -
4:21 - Picker select spacing
::picker(select) { appearance: base-select; padding: 4px; margin-top: 0.5em; } -
4:28 - Picker select border and shadow
::picker(select) { appearance: base-select; padding: 4px; margin-top: 0.5em; border: 1px solid rgba(0,0,0,0.2); border-radius: 9px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); } -
4:36 - Custom option styles
option:checked { font-weight: 600; } option:not(:checked) { color: #777; } -
4:42 - Picker option checkmark
option::checkmark { content: url(checkmark.svg); width: 0.65em; } -
5:31 - Images in option
<option value="flower"> <img src="flowers.svg" alt=""> <span class="text">Flowers</span> </option> -
5:52 - Custom option highlight
option::checkmark { display: none; } option:checked { background: #00857e; color: white; } -
6:20 - Grid layout in drop downs
::picker(select) { display: grid; grid-template: 1fr 1fr / 1fr 1fr 1fr; gap: 1rem; } -
6:43 - Select with image options
<select> <option value="anywhere"> <img src="icons/all.svg" alt=""> <span class="text">Everything</span> </option> <option value="buildings"> <img src="icons/buildings.svg" alt=""> <span class="text">Buildings</span> </option> <option value="flowers"> <img src="icons/flower.svg" alt=""> <span class="text">Flowers</span> </option> </select> -
7:11 - Select menu
<select> <option> </option> <option> </option> <option> </option> </select> -
7:13 - Select menu button
<select> <button> </button> <option> </option> <option> </option> <option> </option> </select> -
7:29 - SelectedContent Element
<select> <button> <selectedcontent></selectedcontent> </button> <option> </option> <option> </option> <option> </option> </select>
-
-
- 0:00 - Introduction
Introducing Customizable Select, a way to fully style the HTML Select Element in CSS while keeping its built-in accessibility, available in Safari 27 and Chrome 135. Follow along as a "Sort by" menu and a category picker are built to fit right into a photographer's portfolio site.
- 2:32 - Style the select button
Apply `appearance: base-select` to opt into the new styling model, then customize the button with familiar CSS — fonts, background, border, and padding. Use the new `::picker-icon` pseudo-element to swap the dropdown arrow, and the `:open` pseudo-class to change colors when the menu is showing.
- 3:47 - Customize the drop-down
Style the menu itself by applying `appearance: base-select` to the `::picker(select)` pseudo-element. Adjust spacing, borders, and box-shadow, emphasize the active option with the `:checked` pseudo-class, and replace the default checkmark using `::checkmark`.
- 5:00 - Go beyond text options
Place rich content like SVG icons, images, or labels directly inside
- 6:50 - The selectedcontent element
Replace the built-in select button by placing a
- 7:46 - Fallback for unsupported browsers
Browsers that don't support customizable select fall back to the native popup automatically — progressive enhancement just works because you're still using a semantic
- 8:49 - Next steps
Try the demo on webkit.org, experiment with customizable select in your own projects, and test against assistive tools and non-supporting browsers. To see the Grid Lanes layout used to display the photos, watch "Learn CSS Grid Lanes."