@@ -85,23 +85,28 @@ Add this CSS sample to keep it at the top of the screen and style the buttons:
85
85
height : 30px ;
86
86
background : #329ea3 ;
87
87
user-select : none ;
88
- display : flex ;
89
- justify-content : flex-end ;
88
+ display : grid ;
89
+ grid-template-columns : auto max-content ;
90
90
position : fixed ;
91
91
top : 0 ;
92
92
left : 0 ;
93
93
right : 0 ;
94
94
}
95
- .titlebar-button {
95
+ .titlebar > .controls {
96
+ display : flex ;
97
+ }
98
+ .titlebar button {
99
+ appearance : none ;
100
+ padding : 0 ;
101
+ margin : 0 ;
102
+ border : none ;
96
103
display : inline-flex ;
97
104
justify-content : center ;
98
105
align-items : center ;
99
106
width : 30px ;
100
- height : 30px ;
101
- user-select : none ;
102
- -webkit-user-select : none ;
107
+ background-color : transparent ;
103
108
}
104
- .titlebar- button :hover {
109
+ .titlebar button :hover {
105
110
background : #5bbec3 ;
106
111
}
107
112
```
@@ -111,27 +116,50 @@ Add this CSS sample to keep it at the top of the screen and style the buttons:
111
116
Put this at the top of your ` <body> ` tag:
112
117
113
118
``` html
114
- <div data-tauri-drag-region class =" titlebar" >
115
- <div class =" titlebar-button" id =" titlebar-minimize" >
116
- <img
117
- src =" https://api.iconify.design/mdi:window-minimize.svg"
118
- alt =" minimize"
119
- />
120
- </div >
121
- <div class =" titlebar-button" id =" titlebar-maximize" >
122
- <img
123
- src =" https://api.iconify.design/mdi:window-maximize.svg"
124
- alt =" maximize"
125
- />
126
- </div >
127
- <div class =" titlebar-button" id =" titlebar-close" >
128
- <img src =" https://api.iconify.design/mdi:close.svg" alt =" close" />
119
+ <div class =" titlebar" >
120
+ <div data-tauri-drag-region ></div >
121
+ <div class =" controls" >
122
+ <button id =" titlebar-minimize" title =" minimize" >
123
+ <!-- https://api.iconify.design/mdi:window-minimize.svg -->
124
+ <svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" >
125
+ <path fill =" currentColor" d =" M19 13H5v-2h14z" /><path >
126
+ </svg >
127
+ </button >
128
+ <button id =" titlebar-maximize" title =" maximize" >
129
+ <!-- https://api.iconify.design/mdi:window-maximize.svg -->
130
+ <svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" >
131
+ <path fill =" currentColor" d =" M4 4h16v16H4zm2 4v10h12V8z" />
132
+ </svg >
133
+ </button >
134
+ <button id =" titlebar-close" title =" close" >
135
+ <!-- https://api.iconify.design/mdi:close.svg -->
136
+ <svg xmlns =" http://www.w3.org/2000/svg" width =" 24" height =" 24" viewBox =" 0 0 24 24" >
137
+ <path
138
+ fill =" currentColor"
139
+ d =" M13.46 12L19 17.54V19h-1.46L12 13.46L6.46 19H5v-1.46L10.54 12L5 6.46V5h1.46L12 10.54L17.54 5H19v1.46z"
140
+ />
141
+ </svg >
142
+ </button >
129
143
</div >
130
144
</div >
131
145
```
132
146
133
147
Note that you may need to move the rest of your content down so that the titlebar doesn't cover it.
134
148
149
+ :::tip
150
+
151
+ On Windows, if you just want a title bar that doesn't need custom interactions, you can use
152
+
153
+ ``` css
154
+ * [data-tauri-drag-region ] {
155
+ app-region : drag;
156
+ }
157
+ ```
158
+
159
+ to make the title bar work with touch and pen inputs
160
+
161
+ :::
162
+
135
163
#### JavaScript
136
164
137
165
Use this code snippet to make the buttons work:
0 commit comments