Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
textfield.h
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
4#pragma once
5
6#include <QtCore/qobject.h>
7#include <QtQml/qqmlregistration.h>
8
9#include "measurementtokens.h"
10#include "shapetokens.h"
11
12// Component values map to the AndroidX Material 3 generated tokens:
13// https://android.googlesource.com/platform/frameworks/support/+/5ba2cdd61be7b6945db999b238d14f3c626136fb/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/tokens/
14// FilledTextFieldTokens.kt (VERSION: v0_210) and OutlinedTextFieldTokens.kt (VERSION: v0_103).
15// Layout values follow the
16// AndroidX Material 3 TextField implementation at the same pinned revision.
17
18namespace Fluid {
19
22{
23 Q_GADGET
24 QML_ANONYMOUS
25
26 Q_PROPERTY(qreal minimumWidth READ minimumWidth CONSTANT FINAL)
27 Q_PROPERTY(qreal containerHeight READ containerHeight CONSTANT FINAL)
28 Q_PROPERTY(qreal horizontalPadding READ horizontalPadding CONSTANT FINAL)
29 Q_PROPERTY(qreal contentVerticalPadding READ contentVerticalPadding CONSTANT FINAL)
30 Q_PROPERTY(qreal supportingTextTopSpace READ supportingTextTopSpace CONSTANT FINAL)
31 Q_PROPERTY(qreal supportingTextMinimumHeight READ supportingTextMinimumHeight CONSTANT FINAL)
32 Q_PROPERTY(qreal prefixSuffixTextSpace READ prefixSuffixTextSpace CONSTANT FINAL)
33 Q_PROPERTY(qreal iconSize READ iconSize CONSTANT FINAL)
34 Q_PROPERTY(qreal iconTargetSize READ iconTargetSize CONSTANT FINAL)
36 Q_PROPERTY(qreal filledActiveIndicatorHeight READ filledActiveIndicatorHeight CONSTANT FINAL)
38 FINAL)
40 CONSTANT FINAL)
42 FINAL)
45 Q_PROPERTY(
48 Q_PROPERTY(qreal outlinedOutlineWidth READ outlinedOutlineWidth CONSTANT FINAL)
49 Q_PROPERTY(qreal outlinedHoverOutlineWidth READ outlinedHoverOutlineWidth CONSTANT FINAL)
50 Q_PROPERTY(qreal outlinedDisabledOutlineWidth READ outlinedDisabledOutlineWidth CONSTANT FINAL)
51 Q_PROPERTY(qreal outlinedFocusOutlineWidth READ outlinedFocusOutlineWidth CONSTANT FINAL)
52 Q_PROPERTY(
54 Q_PROPERTY(
56 Q_PROPERTY(qreal disabledContentOpacity READ disabledContentOpacity CONSTANT FINAL)
57
58public:
60 constexpr qreal minimumWidth() const
61 {
62 return 280.0;
63 }
64
66 constexpr qreal containerHeight() const
67 {
68 return 56.0;
69 }
70
72 constexpr qreal horizontalPadding() const
73 {
74 return 16.0;
75 }
76
78 constexpr qreal contentVerticalPadding() const
79 {
80 return 8.0;
81 }
82
84 constexpr qreal supportingTextTopSpace() const
85 {
86 return 4.0;
87 }
88
90 constexpr qreal supportingTextMinimumHeight() const
91 {
92 return 16.0;
93 }
94
96 constexpr qreal prefixSuffixTextSpace() const
97 {
98 return 2.0;
99 }
100
102 constexpr qreal iconSize() const
103 {
104 return 24.0;
105 }
106
108 constexpr qreal iconTargetSize() const
109 {
111 }
112
115 {
117 }
118
120 constexpr qreal filledActiveIndicatorHeight() const
121 {
122 return 1.0;
123 }
124
126 constexpr qreal filledHoverActiveIndicatorHeight() const
127 {
128 return 1.0;
129 }
130
133 {
134 return 1.0;
135 }
136
138 constexpr qreal filledFocusActiveIndicatorHeight() const
139 {
140 return 2.0;
141 }
142
145 {
146 return 0.38;
147 }
148
150 constexpr qreal filledDisabledContainerOpacity() const
151 {
152 return 0.04;
153 }
154
157 {
158 return ShapeTokens{ }.cornerExtraSmall();
159 }
160
162 constexpr qreal outlinedOutlineWidth() const
163 {
164 return 1.0;
165 }
166
168 constexpr qreal outlinedHoverOutlineWidth() const
169 {
170 return 1.0;
171 }
172
174 constexpr qreal outlinedDisabledOutlineWidth() const
175 {
176 return 1.0;
177 }
178
180 constexpr qreal outlinedFocusOutlineWidth() const
181 {
182 return 2.0;
183 }
184
186 constexpr qreal outlinedDisabledOutlineOpacity() const
187 {
188 return 0.12;
189 }
190
192 constexpr qreal outlinedLabelHorizontalPadding() const
193 {
194 return 4.0;
195 }
196
198 constexpr qreal disabledContentOpacity() const
199 {
200 return 0.38;
201 }
202};
203
204} // namespace Fluid
Material Design 3 system measurement tokens.
QML_ANONYMOUSqreal minimumInteractiveSize
Material Design 3 system shape tokens.
Definition shapetokens.h:48
Fluid::ShapeValue cornerExtraSmall
Definition shapetokens.h:57
Fluid::ShapeValue cornerExtraSmallTop
Definition shapetokens.h:58
Material Design 3 tokens for text fields.
Definition textfield.h:22
constexpr qreal containerHeight() const
Minimum height of the text-field container.
Definition textfield.h:66
qreal outlinedFocusOutlineWidth
Definition textfield.h:51
constexpr qreal horizontalPadding() const
Logical horizontal padding around text-field content.
Definition textfield.h:72
qreal filledDisabledActiveIndicatorOpacity READ filledDisabledActiveIndicatorOpacity
Definition textfield.h:44
qreal filledDisabledContainerOpacity
Definition textfield.h:46
qreal filledFocusActiveIndicatorHeight
Definition textfield.h:42
Fluid::ShapeValue outlinedContainerShape
Definition textfield.h:47
constexpr qreal disabledContentOpacity() const
Opacity of text-field content when disabled.
Definition textfield.h:198
constexpr qreal filledDisabledActiveIndicatorOpacity() const
Opacity of a filled text field's active indicator when disabled.
Definition textfield.h:144
qreal prefixSuffixTextSpace
Definition textfield.h:32
qreal disabledContentOpacity
Definition textfield.h:56
qreal supportingTextMinimumHeight
Definition textfield.h:31
constexpr qreal outlinedLabelHorizontalPadding() const
Horizontal padding around a floated outlined-field label.
Definition textfield.h:192
constexpr qreal contentVerticalPadding() const
Vertical padding around text-field content.
Definition textfield.h:78
constexpr ShapeValue filledContainerShape() const
Shape of a filled text-field container.
Definition textfield.h:114
qreal horizontalPadding
Definition textfield.h:28
qreal filledDisabledActiveIndicatorHeight
Definition textfield.h:40
qreal outlinedDisabledOutlineOpacity
Definition textfield.h:53
constexpr qreal supportingTextTopSpace() const
Space between the container and supporting or error text.
Definition textfield.h:84
constexpr qreal iconSize() const
Visual size of leading and trailing icons.
Definition textfield.h:102
constexpr qreal filledDisabledContainerOpacity() const
Opacity of a filled text-field container when disabled.
Definition textfield.h:150
QML_ANONYMOUSqreal minimumWidth
Definition textfield.h:26
constexpr ShapeValue outlinedContainerShape() const
Shape of an outlined text-field container.
Definition textfield.h:156
constexpr qreal iconTargetSize() const
Minimum target size reserved for leading and trailing icon slots.
Definition textfield.h:108
qreal outlinedDisabledOutlineWidth
Definition textfield.h:50
constexpr qreal outlinedDisabledOutlineOpacity() const
Opacity of an outlined text field's outline when disabled.
Definition textfield.h:186
constexpr qreal filledFocusActiveIndicatorHeight() const
Focused thickness of a filled text field's active indicator.
Definition textfield.h:138
constexpr qreal filledDisabledActiveIndicatorHeight() const
Disabled thickness of a filled text field's active indicator.
Definition textfield.h:132
constexpr qreal prefixSuffixTextSpace() const
Space between input text and prefix or suffix text.
Definition textfield.h:96
constexpr qreal outlinedDisabledOutlineWidth() const
Disabled thickness of an outlined text field's outline.
Definition textfield.h:174
qreal filledHoverActiveIndicatorHeight
Definition textfield.h:38
qreal iconTargetSize
Definition textfield.h:34
qreal outlinedLabelHorizontalPadding
Definition textfield.h:55
constexpr qreal outlinedHoverOutlineWidth() const
Hovered thickness of an outlined text field's outline.
Definition textfield.h:168
qreal filledActiveIndicatorHeight
Definition textfield.h:36
qreal outlinedHoverOutlineWidth
Definition textfield.h:49
constexpr qreal filledHoverActiveIndicatorHeight() const
Hovered thickness of a filled text field's active indicator.
Definition textfield.h:126
qreal supportingTextTopSpace
Definition textfield.h:30
constexpr qreal outlinedOutlineWidth() const
Resting thickness of an outlined text field's outline.
Definition textfield.h:162
constexpr qreal filledActiveIndicatorHeight() const
Resting thickness of a filled text field's active indicator.
Definition textfield.h:120
qreal outlinedOutlineWidth
Definition textfield.h:48
qreal containerHeight
Definition textfield.h:27
constexpr qreal supportingTextMinimumHeight() const
Minimum height reserved for supporting or error text.
Definition textfield.h:90
constexpr qreal outlinedFocusOutlineWidth() const
Focused thickness of an outlined text field's outline.
Definition textfield.h:180
qreal contentVerticalPadding
Definition textfield.h:29
Fluid::ShapeValue filledContainerShape
Definition textfield.h:35