@@ -85,23 +85,28 @@ Add this CSS sample to keep it at the top of the screen and style the buttons:
8585 height : 30px ;
8686 background : #329ea3 ;
8787 user-select : none ;
88- display : flex ;
89- justify-content : flex-end ;
88+ display : grid ;
89+ grid-template-columns : auto max-content ;
9090 position : fixed ;
9191 top : 0 ;
9292 left : 0 ;
9393 right : 0 ;
9494}
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 ;
96103 display : inline-flex ;
97104 justify-content : center ;
98105 align-items : center ;
99106 width : 30px ;
100- height : 30px ;
101- user-select : none ;
102- -webkit-user-select : none ;
107+ background-color : transparent ;
103108}
104- .titlebar- button :hover {
109+ .titlebar button :hover {
105110 background : #5bbec3 ;
106111}
107112```
@@ -111,27 +116,50 @@ Add this CSS sample to keep it at the top of the screen and style the buttons:
111116Put this at the top of your ` <body> ` tag:
112117
113118``` 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 >
129143 </div >
130144</div >
131145```
132146
133147Note that you may need to move the rest of your content down so that the titlebar doesn't cover it.
134148
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+
135163#### JavaScript
136164
137165Use this code snippet to make the buttons work:
0 commit comments