You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Proposal: Classless dropdown component leveraging the Popover API
I would like to propose a classless Dropdown component built with the native Popover API.
Pico currently provides a Dropdown component through its class-based stylesheet, but the component is not available when using the Classless version. A native popover-based implementation could provide equivalent dropdown behavior without requiring a component class or JavaScript.
The proposed structure uses a button as the trigger and a nested unordered list as the dropdown content:
This structure preserves the semantic markup used within Pico class-based Dropdown component while relying on native browser behavior for opening and closing the dropdown.
The <button> remains responsible for toggling the dropdown through popovertarget.
The popover attribute provides native light-dismiss behavior.
The <ul> identifies the dropdown contents as a list of related navigation items.
CSS Anchor Positioning places the dropdown relative to its trigger.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Proposal: Classless dropdown component leveraging the Popover API
I would like to propose a classless Dropdown component built with the native Popover API.
Pico currently provides a Dropdown component through its class-based stylesheet, but the component is not available when using the Classless version. A native popover-based implementation could provide equivalent dropdown behavior without requiring a component class or JavaScript.
The proposed structure uses a button as the trigger and a nested unordered list as the dropdown content:
This structure preserves the semantic markup used within Pico class-based Dropdown component while relying on native browser behavior for opening and closing the dropdown.
<button>remains responsible for toggling the dropdown throughpopovertarget.popoverattribute provides native light-dismiss behavior.<ul>identifies the dropdown contents as a list of related navigation items.The trigger can be established as an anchor:
The popover can then be positioned and styled using selectors based entirely on native HTML attributes:
The result would be a dropdown component that fits naturally within Pico Classless.
Fiddle: https://jsfiddle.net/vreabyhk/
All reactions