Skip to content

[css-values] Add clamp()? #2519

@xfq

Description

@xfq

For background, see discussions starting at #544 (comment)


It would be useful to add a clamp() function. Two kinds of argument order were proposed in #544:

  • (min, value, max)
  • (value, min, max)

Both of them have precedents[1][2]. (I personally prefer the (min, value, max) version.)

Although authors can emulate it by combining max() and min(), the clamp() function can avoid the confusion caused by the emulation.

The behavior of clamp() on <angle> and <color> also needs some thoughts.


Links:

[1] clamp in the Boost Algorithm Library
[2] qBound in Qt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions