npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2024 – Pkg Stats / Ryan Hefner

tauri-window-controls-react

v0.3.0

Published

πŸš₯ Native-looking window controls for Tauri 2.

Downloads

4

Readme

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:
bun add tauri-window-controls

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

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

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

License

MIT