Skip to content

Add declarative scroll commands to HTMLButtonElement #11847

@danielsakhapov

Description

@danielsakhapov

What problem are you trying to solve?

Authors frequently build custom components that contain a scrollable region, such as:

A horizontal carousel of products or images.
A vertically scrolling list of items within a modal.
A 2D scrolling area for a map or canvas.

These components almost always require custom "Next," "Previous," "Up," or "Down" buttons. Currently, authors must write JavaScript to wire these buttons up. This proposal moves this common, repetitive behavior into the platform, making it declarative, robust, and accessible by default.

What solutions exist today?

Button activation handlers in JavaScript

How would you solve it?

The proposal is to add eight new enumerated values to the command attribute on HTMLButtonElement. These commands would be paired with the commandfor attribute, which targets the id of the scroll container.

Proposed command values
Physical directions:
page-up
page-down
page-left
page-right
Logical directions:
page-block-start
page-block-end
page-inline-start
page-inline-end

Anything else?

Full proposal explainer: https://github.com/danielsakhapov/declarative-scroll-commands-for-html-explainer
OpenUI discussion: openui/open-ui#1220

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interesttopic: buttonThe <button> element.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions