Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
Breakpoints.qml
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-License-Identifier: MPL-2.0
3
4pragma Singleton
5
6import QtQuick
7import Fluid as MD
8
27QtObject {
37 enum Breakpoint {
38 Compact,
39 Medium,
40 Expanded,
41 Large,
42 ExtraLarge
43 }
44
46 readonly property real compactLowerBound: 0
47
49 readonly property real mediumLowerBound: 600
50
52 readonly property real expandedLowerBound: 840
53
55 readonly property real largeLowerBound: 1200
56
58 readonly property real extraLargeLowerBound: 1600
59
65 function fromWidth(width) {
66 if (typeof width !== "number" || !Number.isFinite(width) || width < compactLowerBound)
67 return Breakpoints.Compact;
68 if (width >= extraLargeLowerBound)
69 return Breakpoints.ExtraLarge;
70 if (width >= largeLowerBound)
71 return Breakpoints.Large;
72 if (width >= expandedLowerBound)
73 return Breakpoints.Expanded;
74 if (width >= mediumLowerBound)
75 return Breakpoints.Medium;
76 return Breakpoints.Compact;
77 }
78
86 function columnCount(breakpoint) {
87 switch (breakpoint) {
88 case Breakpoints.Medium:
89 case Breakpoints.Expanded:
90 return 8;
91 case Breakpoints.Large:
92 case Breakpoints.ExtraLarge:
93 return 12;
94 case Breakpoints.Compact:
95 default:
96 return 4;
97 }
98 }
99
107 function margin(breakpoint) {
108 switch (breakpoint) {
109 case Breakpoints.Medium:
110 case Breakpoints.Expanded:
111 case Breakpoints.Large:
112 case Breakpoints.ExtraLarge:
113 return MD.Tokens.measurement.space300;
114 case Breakpoints.Compact:
115 default:
116 return MD.Tokens.measurement.space200;
117 }
118 }
119
127 function gutter(breakpoint) {
128 switch (breakpoint) {
129 case Breakpoints.Medium:
130 case Breakpoints.Expanded:
131 case Breakpoints.Large:
132 case Breakpoints.ExtraLarge:
133 return MD.Tokens.measurement.space300;
134 case Breakpoints.Compact:
135 default:
136 return MD.Tokens.measurement.space200;
137 }
138 }
139}
Material Design 3 width breakpoints and adaptive grid metrics.