I’ve been banging on for a while now about how much I’d like a declarative option for the Web Share API. I was thinking that the type attribute on the button element would be a good candidate for this (there’s prior art in the way we extended the type attribute on the input element for HTML5).
I wrote about the reason for a share button type as well as creating a polyfill. I also wrote about how this idea would work for other button types: fullscreen, print, copy to clipboard, that sort of thing.
Since then, I’ve been very interested in the idea of “invokers” being pursued by the Open UI group. Rather than extending the type attribute, they’ve been looking at adding a new attribute. Initially it was called invoketarget (so something like button invoketarget="share").
Things have been rolling along and invoketarget has now become the command attribute (there’s also a new commandfor attribute that you can point to an element with an ID). Here’s a list of potential values for the command attribute on a button element.
Right now they’re focusing on providing declarative options for launching dialogs and other popovers. That’s already shipping.
The next step is to use command and commandfor for controlling audio and video, as well as some form controls. I very much approve! I love the idea of being able to build and style a fully-featured media player without any JavaScript.
I’m hoping that after that we’ll see the command attribute get expanded to cover JavaScript APIs that require a user interaction. These seem like the ideal candidates:
button command="share"button command="fullscreen"button command="print"button command="copy"button command="install"
There’s also scope for declarative options for navigating the browser’s history stack:
button command="back"button command="forward"button command="refresh"
Whatever happens next, I’m very glad to see that so much thinking is being applied to declarative solutions for common interface patterns.
# Shared by Mia (web luddite) on Thursday, March 20th, 2025 at 3:37pm
# Shared by Zach Leatherman on Thursday, March 20th, 2025 at 3:52pm
# Shared by Nilesh Prajapati on Thursday, March 20th, 2025 at 3:52pm
# Shared by Mr Peach on Thursday, March 20th, 2025 at 3:52pm
# Shared by Mia (luddite) on Thursday, March 20th, 2025 at 3:52pm
# Shared by Luke on Thursday, March 20th, 2025 at 4:40pm
# Shared by Kai on Thursday, March 20th, 2025 at 5:11pm
# Shared by Prateek Rungta on Thursday, March 20th, 2025 at 7:13pm
# Shared by Oblomov on Thursday, March 20th, 2025 at 7:44pm
# Shared by Curtis Wilcox on Thursday, March 20th, 2025 at 10:24pm
# Shared by Sebastian Gfeller on Thursday, March 20th, 2025 at 11:30pm
# Shared by Leon Miller on Friday, March 21st, 2025 at 3:01am
# Shared by Thomas Steiner :chrome: on Friday, March 21st, 2025 at 7:30am
# Shared by Léon van Kammen on Friday, March 21st, 2025 at 8:03am
# Shared by Dave 🧱 on Friday, March 21st, 2025 at 6:59pm