1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5 \page qtquickcontrols-universal.html
8 The Universal Style is based on the Microsoft Universal Design Guidelines.
9 \l {detailed-desc-universal}{More...}
11 \styleimport {QtQuick.Controls.Universal 2.12} {Qt 5.7}
13 \section1 Attached Properties
16 \li \l {universal-accent-attached-prop}{\b accent} : color
17 \li \l {universal-background-attached-prop}{\b background} : color
18 \li \l {universal-foreground-attached-prop}{\b foreground} : color
19 \li \l {universal-theme-attached-prop}{\b theme} : enumeration
22 \section1 Attached Methods
25 \li color \l {color-attached-method}{\b color}(enumeration predefined)
28 \section1 Detailed Description
29 \target detailed-desc-universal
31 The Universal style is a device-agnostic style based on the
32 \l {https://dev.windows.com/design}{Microsoft Universal Design Guidelines}.
33 The Universal style has been designed to look good on all devices, from
34 phones and tablets to PCs.
36 \include style-screenshots.qdocinc {file} {Universal} {universal}
38 To run an application with the Universal style, see
39 \l {Using Styles in Qt Quick Controls}.
41 \note The Universal style is not a native Windows 10 style. The Universal
42 style is a 100% cross-platform Qt Quick Controls style implementation that
43 follows the Microsoft Universal Design Guidelines. The style runs on any
44 platform, and looks more or less identical everywhere. Minor differences
45 may occur due to differences in available system fonts and font rendering
48 \section2 Customization
50 The Universal style allows customizing four attributes, \l {universal-theme-attached-prop}{theme},
51 \l {universal-accent-attached-prop}{accent}, \l {universal-foreground-attached-prop}{foreground}, and
52 \l {universal-background-attached-prop}{background}.
54 \image qtquickcontrols-universal-attributes.png
56 Both attributes can be specified for any window or item, and they automatically
57 propagate to children in the same manner as \l {Control::font}{fonts}. In the
58 following example, the window and all three radio buttons appear in the dark
59 theme using a violet accent color:
66 import QtQuick.Controls 2.12
67 import QtQuick.Controls.Universal 2.12
72 Universal.theme: Universal.Dark
73 Universal.accent: Universal.Violet
76 anchors.centerIn: parent
78 RadioButton { text: qsTr("Small") }
79 RadioButton { text: qsTr("Medium"); checked: true }
80 RadioButton { text: qsTr("Large") }
85 \image qtquickcontrols-universal-violet.png
88 In addition to specifying the attributes in QML, it is also possible to
89 specify them via environment variables or in a configuration file. Attributes
90 specified in QML take precedence over all other methods.
92 \section3 Configuration File
94 \include qquickuniversalstyle.qdocinc conf
96 See \l {Qt Quick Controls Configuration File} for more details about the
99 \section3 Environment Variables
101 \include qquickuniversalstyle.qdocinc env
103 See \l {Supported Environment Variables in Qt Quick Controls} for the full
104 list of supported environment variables.
108 The Universal style must be separately imported to gain access to the
109 attributes that are specific to the Universal style. It should be noted
110 that regardless of the references to the Universal style, the same
111 application code runs with any other style. Universal-specific attributes
112 only have an effect when the application is run with the Universal style.
114 If the Universal style is imported in a QML file that is always loaded, the
115 Universal style must be deployed with the application in order to be able
116 to run the application regardless of which style the application is run with.
117 By using \l {Using File Selectors with Qt Quick Controls}{file selectors},
118 style-specific tweaks can be applied without creating a hard dependency to
121 \section2 Pre-defined Universal Colors
123 Available pre-defined colors:
124 \value Universal.Lime \stylecolor {#A4C400} {}
125 \value Universal.Green \stylecolor {#60A917} {}
126 \value Universal.Emerald \stylecolor {#008A00} {}
127 \value Universal.Teal \stylecolor {#00ABA9} {}
128 \value Universal.Cyan \stylecolor {#1BA1E2} {}
129 \value Universal.Cobalt \stylecolor {#3E65FF} {(default accent)}
130 \value Universal.Indigo \stylecolor {#6A00FF} {}
131 \value Universal.Violet \stylecolor {#AA00FF} {}
132 \value Universal.Pink \stylecolor {#F472D0} {}
133 \value Universal.Magenta \stylecolor {#D80073} {}
134 \value Universal.Crimson \stylecolor {#A20025} {}
135 \value Universal.Red \stylecolor {#E51400} {}
136 \value Universal.Orange \stylecolor {#FA6800} {}
137 \value Universal.Amber \stylecolor {#F0A30A} {}
138 \value Universal.Yellow \stylecolor {#E3C800} {}
139 \value Universal.Brown \stylecolor {#825A2C} {}
140 \value Universal.Olive \stylecolor {#6D8764} {}
141 \value Universal.Steel \stylecolor {#647687} {}
142 \value Universal.Mauve \stylecolor {#76608A} {}
143 \value Universal.Taupe \stylecolor {#87794E} {}
145 \b {See also} \l {Basic Style}, \l {Material Style}
147 \section1 Attached Property Documentation
149 \styleproperty {Universal.accent} {color} {universal-accent-attached-prop}
150 \target universal-accent-attached-prop
151 This attached property holds the accent color of the theme. The property
152 can be attached to any window or item. The value is propagated to children.
154 The default value is \c Universal.Cobalt.
156 In the following example, the accent color of the highlighted button is
157 changed to \c Universal.Orange:
162 \snippet qtquickcontrols-universal-accent.qml 1
164 \image qtquickcontrols-universal-accent.png
167 \note Even though the accent can be any \l {colorvaluetypedocs}{color}, it is
168 recommended to use one of the \l {pre-defined Universal colors} that have been
169 designed to work well with the rest of the Universal style palette.
173 \styleproperty {Universal.background} {color} {universal-background-attached-prop}
174 \target universal-background-attached-prop
175 This attached property holds the background color of the theme. The property
176 can be attached to any window or item. The value is propagated to children.
178 The default value is theme-specific (light or dark).
180 In the following example, the background color of the pane is changed to
186 \snippet qtquickcontrols-universal-background.qml 1
188 \image qtquickcontrols-universal-background.png
193 \styleproperty {Universal.foreground} {color} {universal-foreground-attached-prop}
194 \target universal-foreground-attached-prop
195 This attached property holds the foreground color of the theme. The property
196 can be attached to any window or item. The value is propagated to children.
198 The default value is theme-specific (light or dark).
200 In the following example, the foreground color of the button is set to \c
206 \snippet qtquickcontrols-universal-foreground.qml 1
208 \image qtquickcontrols-universal-foreground.png
211 \styleproperty {Universal.theme} {enumeration} {universal-theme-attached-prop}
212 \target universal-theme-attached-prop
213 This attached property holds whether the theme is light or dark. The property
214 can be attached to any window or item. The value is propagated to children.
217 \value Universal.Light Light theme (default)
218 \value Universal.Dark Dark theme
219 \value Universal.System System theme
221 Setting the theme to \c System chooses either the light or dark theme based
222 on the system theme colors. However, when reading the value of the theme
223 property, the value is never \c System, but the actual theme.
225 In the following example, the theme for both the pane and the button is set
226 to \c Universal.Dark:
231 \snippet qtquickcontrols-universal-theme.qml 1
233 \image qtquickcontrols-universal-theme.png
238 \section1 Attached Method Documentation
240 \stylemethod {color} {color} {enumeration} {predefined} {color-attached-method}
241 \target color-attached-method
242 This attached method returns the effective color value of the specified
243 \l {pre-defined Universal colors}{pre-defined Universal color}.
247 color: Universal.color(Universal.Red)
253 \section1 Related Information
256 \li \l{Styling Qt Quick Controls}