A select menu that wraps round its own button
I wanted to know if the menu of a <select> could open over its own button, with the button's shape cut out of one
corner and the options flowing round the cut the way words flow round a picture. The idea is the
Punch-Out Dropdown by Fabio Azevedo
(his post). I haven't read his code, and none of it is here.
Each control below is one <select> with appearance: base-select. A canvas inside its picker draws the menu
and the options, as on /select/.
- Nothing pressed yet.
How it works
The picker is placed with CSS anchor positioning so that its corner is 7 px outside the button's corner. It has three
@position-try rules, so near the right edge it lines up with the button's right side, and near the bottom of the window it opens
upwards. On each frame the layout reads where the button is under the canvas, draws the menu as one path with that corner missing, and
breaks the options into lines. A line level with the button is shorter than the others.
The report that suggested this page said to erase the button's rectangle from the picture with destination-out. That makes the
hole visible, but the button under it still can't be pressed. Two boxes are in the way, and neither has a pixel there: the picker's own
box and the canvas. So the picker has pointer-events: none, its canvas has pointer-events: auto, and the canvas has
a clip-path with the same corner missing. I draw an L-shaped path in place of erasing, because the outline and the shadow then
follow the cut.
Show the code the layout, the option flow and the page
- Three ordinary selects. The options are written in the HTML.
- The page script gives each select the picker and logs what was pressed.
- Where the picker goes.
anchor()on the picker, three fallbacks, and the twopointer-eventslines. - The menu's outline. Six points and
arcTo(). - The option flow. Lines level with the cut are shorter.
- The layout.
prepare()measures the button and sets theclip-path.place()gives each option its matrix.under()draws the menu. punchOut(select).- The drawing loop in the picker library that calls the layout.
- The page's CSS for the closed select and the options.
Live checks
These open a small test select in a panel at the bottom of the window. They wait for a tap because a picker only opens after one.
Findings
- A hole in the picture isn't a hole in the canvas. The canvas draws nothing where the button is (alpha 0, read in a live check), and with nothing else done
elementFromPoint()at the button still returns the canvas. A second press on the button does nothing and the menu stays open. Clear the checkbox above to see it. - The picker's own box takes the press too, and
elementFromPoint()doesn't show it. With the corner cut from the canvas byclip-pathand nothing else,elementFromPoint()at the button returned the select, and so did thepointerdownandclicktargets, but the menu stayed open. The press was on::picker(select), which has no background here, and events from it are reported as the select's. Withpointer-events: noneon the picker andautoon its canvas, the same press closed the menu onmousedown. - I found three routes to the button and kept the first. One:
pointer-events: noneon the picker and aclip-pathon the canvas. Two:pointer-events: noneon the canvas andautoon the options, which frees the button but also lets a press between two options through to the page behind the menu. Three: aclip-pathon::picker(select)alone, which closed the menu with one declaration but cut the menu's shadow off at the picker's box. clip-pathon a drawable canvas left the options alone. All of them are still drawn and hit at their centres. The clip is apath()with the button's corner radius in it, so the menu's shadow in the 7 px gap ends on the button's edge.anchor()on::picker(select)neededposition-anchor: auto. Withposition-area: noneand noposition-anchor,left: anchor(left)computed to 0 and the picker opened in the top left corner of the window. With it, the picker follows the button, and when I moved the test button to the other end of its row with the picker open the cut moved with it.@position-tryworks on the picker. The three rules pick the corner. I made the picker's box the menu's box and gave the canvas a negative margin of 18 px for the shadow. When the canvas was the picker's whole box, a button 16 px from the left edge counted as overflowing and the first fallback was taken.- The options keep their order when the menu opens upwards. Lines are filled from the cut outwards. With the button at the bottom the flow starts from the last option, so the short line beside the button holds the last options and the part-empty line is the top one. Arrow keys move in DOM order, which is the order on screen.
- The canvas gets its height one frame late. The height depends on the options' widths, which can't be measured until the picker is open. The first frame is drawn at 300 px with the options at alpha 0, and the next frame has the right height.
- The press that opens the menu ends on the canvas. With a mouse the menu opens on
mousedown, before the first frame has set theclip-path, so thepointerupof that press has the canvas as its target. Theclickstill goes to the select and nothing is chosen. - Not verified on real hardware. Measured on 2026-11-24 in Chromium 157 without a window, driven by Playwright with a mouse, the keyboard and emulated touch at 412 px. I haven't pressed the button through the cut with a finger on Android Chrome, and I haven't tried the fallbacks with the on-screen keyboard up.