• Stars
    star
    465
  • Rank 94,287 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 1 year ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸš₯ Native-looking window controls for Tauri 2. React, Solid, Vue, Svelte+Tailwind.
Tauri Controls

SolidJS Vue.js

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.

The following designs are taken as reference:

How to use

Install Dependencies

# React:
pnpm add tauri-controls

# Svelte:
pnpm add @tauri-controls/svelte

# Solid.js:
pnpm add @tauri-controls/solid

# Vue.js:
pnpm add @tauri-controls/vue
# Install peer dependencies:
pnpm add @tauri-apps/plugin-os @tauri-apps/plugin-window
pnpm add -D clsx tailwind-merge

For Svelte projects, include the following line in the content section of your tailwind.config.js:

"./node_modules/@tauri-controls/svelte/**/*.{js,svelte,ts}"

Then, make sure to include the following tauri plugins in your src-tauri directory:

cargo add tauri-plugin-window tauri-plugin-os

Don't forget to register plugins in your main function.

fn main() {
    tauri::Builder::default()
        .plugin(tauri_plugin_os::init())
        .plugin(tauri_plugin_window::init())
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

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"

function MyTitlebar() {
  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.

import { WindowControls } from "tauri-controls"

function MyTitlebar() {
  return <WindowControls />
}

More examples:

Options

WindowTitlebar:

  • 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.

Example Example

Figma

Check out the design implementation on Figma for a visual reference. Desktop Native Window Controls - Figma.

These sources were utilized:

Development and Contribution

pnpm dev

pnpm tauri:dev

Project Structure:

.
β”œβ”€β”€ /apps
β”‚   β”œβ”€β”€ /tauri-controls            # Main application (React)
β”‚   β”œβ”€β”€ /tauri-controls-solid      # Solid.js implementation
β”‚   └── /tauri-controls-svelte     # Svelte implementation
β”œβ”€β”€ /packages                       # Shared packages
β”œβ”€β”€ package.json                    # Project configuration
β”œβ”€β”€ pnpm-workspace.yaml             # Workspace configuration
└── turbo.json                      # TurboRepo configuration

If you're interested in contributing, check out our TODO list for tasks you can help with. Your contributions are appreciated!

Contributors

This project is made possible by the contributions of various individuals. Thank you to all the contributors who have helped make this project better.

Further Reading

License

MIT

More Repositories

1

awesome-blender

πŸͺ A curated list of awesome Blender addons, tools, tutorials; and 3D resources for everyone.
3,874
star
2

tauri-ui

πŸ¦€ Create modern Tauri desktop apps in just a few simple steps with shadcn/ui. React, Next.js, Sveltekit.
TypeScript
890
star
3

turkish-nlp-resources

πŸ”‘ List of Tools, Libraries, Models, Datasets and other resources for Turkish NLP.
79
star
4

polydown

Batch downloader for polyhaven.com. Download 'HDRIs, Textures and Models' in any sizes with preview images from Poly Haven.
Python
31
star
5

fineartdown

Download high-resolution images from Fine Art America, Conde Nast Store, Photos.com, and Pixels.com. "the current reverse engineering approach is non-functional."
TypeScript
26
star
6

syn

🌾 Get synonyms and antonyms of words from Thesaurus.com and other sources in your terminal, with rich output.
Python
26
star
7

tauri-spotify-clone

Spotify desktop app clone built with Tauri and Tailwind, with basic functionality.
TypeScript
21
star
8

textual-filedrop

FileDrop widget for Textual, easily drag and drop files into your terminal apps.
Python
21
star
9

badgewind

β–± Tailwind-styled markdown SVG badges, basically shields.io but customizable with Tailwind.
TypeScript
17
star
10

tr-domains

List of .tr domains, contains 200k live domains.
Jupyter Notebook
10
star
11

tdk-cli

Command-line tool for TDK Dictionary, sozluk.gov.tr with rich output.
Python
10
star
12

nisanyan-cli

CLI tool for Turkish etymological dictionary, nisanyansozluk.com
Python
9
star
13

houdini-resources

Various tools, tutorials and resources for Houdini.
8
star
14

etytree

Shows etymological relations as a tree diagram.
TypeScript
7
star
15

dezoomify-rs-gui

GUI for dezoomify-rs the tiled image downloader from Google Arts & Culture, Zoomify, IIIF, and others.
Python
5
star
16

create-tauri-ui

Create Tauri UI in just a few simple steps.
TypeScript
4
star
17

starred

agmmnn's starred repos, updated daily! ✨
3
star
18

nis-scraper

Scrapy script to scrape nisanyansozluk.com
Python
3
star
19

etymap

Interactive etymology map
TypeScript
3
star
20

random-repo-img

🧀A simple flask app to pick and return a random image from the given github repo folder.
HTML
3
star
21

pushkin-downloader

State Historical Museum and The Pushkin Museum Downloader
TypeScript
3
star
22

lugatim-cli

Command-line tool for Kubbealti Lugati: lugatim.com, with rich output.
Python
2
star
23

etym-cli

Show etymological origins of words from etymonline.com in terminal with rich output.
Python
1
star
24

turengcli

Command-line tool for tureng.com with rich output.
Python
1
star
25

eksitui

TUI for the Turkish collaborative hypertext dictionary ekşi sâzlük.
Python
1
star
26

datamuse-cli

A command line interface that displays results from the Datamuse API.
Python
1
star
27

agmmnn

1
star
28

agmmnn.dev

Astro
1
star
29

radyal-api

Provides some useful API endpoints.
JavaScript
1
star
30

agmmnn.github.io

1
star
31

wordwhisper

find releated words
Svelte
1
star
32

security-list

1
star
33

eksiflow

ekşi sâzlük canlı akış uygulaması. *wip* https://eksiflow.vercel.app
JavaScript
1
star