Tauri Controls is a library that provides native-looking window controls for Tauri 2 applications. You can enhance the user experience of your Tauri 2 applications with window controls that mimic the identical native controls on the current system.
tauri-controls uses Tauri's js/ts APIs to handle window events and just provides native-looking (designed according to official system design prototypes) html elements, not native, it does not rely on the system's native APIs.
# React:
bun add tauri-controls
# Svelte:
bun add @tauri-controls/svelte
# Solid.js:
bun add @tauri-controls/solid
# Vue.js:
bun add @tauri-controls/vue
# Install peer dependencies:
bun add @tauri-apps/plugin-os @tauri-apps/api
bun add -D clsx tailwind-merge
For Svelte projects, include the following line in the content section of your tailwind.config.js:
If you get the message "Not allowed by scope" in the terminal after a production build, try this.
Add to Your Code
And simply add the WindowTitlebar or WindowControls component to your code, depending on your needs:
WindowTitlebar
The WindowTitlebar component handles the window titlebar and dynamically adjusts the window control buttons and titlebar content order based on the current operating system.
import { WindowTitlebar } from"tauri-controls"functionMyTitlebar() {
return (
<WindowTitlebar>{/* Place your titlebar content here */}</WindowTitlebar>
)
}
When no platform is specified, the current system will be detected and the matching element will be returned. This feature is a great solution for cross-platform releases.
WindowControls
Use the WindowControls component only for window controls.
controlsOrder?: "right" | "left" | "platform" | "system": Specifies the order of window controls. platform: to get OS-based positioning specified in windowControlsProps.
system: to automatically detect the platform and position the controls accordingly (default).
windowControlsProps?: WindowControlsProps: Additional props to pass to the WindowControls component.
WindowControls:
platform?: "windows" | "macos" | "gnome": Specifies which platform's window controls to display. If the platform property is not specified, the library will automatically detect the operating system the app is running on and display the appropriate element.
justify?: boolean: If set to true, WindowControls will justify/snap in the flexbox where it is located.
hide?: boolean: If set to true, the window controls will be hidden.
hideMethod?: "display" | "visibility": Determines how the window controls will be hidden.
You can also provide additional props to elements, such as data-tauri-drag-region, for further enhancements.
The npm package tauri-controls receives a total of 110 weekly downloads. As such, tauri-controls popularity was classified as not popular.
We found that tauri-controls demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Ā It has 1 open source maintainer collaborating on the project.
Package last updated on 23 Mar 2024
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.