Viewport characteristics media features
Christopher Schnick
crschnick at xpipe.io
Sat Jul 12 16:03:19 UTC 2025
That is very exciting.
Would it be possible to create custom boolean properties that one can
then use for media queries? For example, having a ObservableMap<String,
ObservableBooleanValue> in the new scene preferences to define custom
features that can then be matched in the stylesheet.
On 12/07/2025 07:16, Michael Strauß wrote:
> JavaFX 25 introduces user-preference media queries, which allows
> developers to probe user preferences in stylesheets.
>
> I propose to enhance media queries by adding the following viewport
> characteristics media features [0]:
> 1. width
> 2. height
> 3. aspect-ratio (=width/height)
> 4. orientation (with values "portrait" and "landscape")
> 5. display-mode (with values "fullscreen" and "standalone")
>
> These additional media features make it easier to create responsive
> user interfaces. For example, a stylesheet could have different styles
> depending on the window width:
>
> @media (width <= 500) {
> // ...
> }
>
> @media (500 < width < 1000) {
> // ...
> }
>
> @media (width >= 1000) {
> // ...
> }
>
> [0] https://www.w3.org/TR/mediaqueries-5/#mf-viewport-characteristics
More information about the openjfx-dev
mailing list