Skip to content

Commit b5439cf

Browse files
authored
feat: port icons guide (#2979)
1 parent a4eb50a commit b5439cf

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

src/content/docs/develop/icons.mdx

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
title: App Icons
3+
sidebar:
4+
order: 1
5+
---
6+
7+
{/* TODO: More platform specific explanations like macOS requiring padding in the icon (waiting for https://github.com/tauri-apps/tauri/pull/11037) */}
8+
9+
import CommandTabs from '@components/CommandTabs.astro';
10+
11+
Tauri ships with a default iconset based on its logo. This is NOT what you want when you ship your application. To remedy this common situation, Tauri provides the `icon` command that will take an input file (`"./app-icon.png"` by default) and create all the icons needed for the various platforms.
12+
13+
:::note[Note on filetypes]
14+
15+
- `icon.icns` = macOS
16+
- `icon.ico` = Windows
17+
- `*.png` = Linux
18+
- `Square*Logo.png` & `StoreLogo.png` = Currently unused but intended for AppX/MS Store targets.
19+
20+
Some icon types may be used on platforms other than those listed above (especially `png`). Therefore we recommend including all icons even if you intend to only build for a subset of platforms.
21+
22+
:::
23+
24+
## Command Usage
25+
26+
<CommandTabs
27+
npm="npm run tauri icon"
28+
yarn="yarn tauri icon"
29+
pnpm="pnpm tauri icon"
30+
cargo="cargo tauri icon"
31+
deno="deno task tauri icon"
32+
/>
33+
34+
```console
35+
> pnpm tauri icon --help
36+
37+
Generate various icons for all major platforms
38+
39+
Usage: pnpm run tauri icon [OPTIONS] [INPUT]
40+
41+
Arguments:
42+
[INPUT] Path to the source icon (squared PNG or SVG file with transparency) [default: ./app-icon.png]
43+
44+
Options:
45+
-o, --output <OUTPUT> Output directory. Default: 'icons' directory next to the tauri.conf.json file
46+
-v, --verbose... Enables verbose logging
47+
-p, --png <PNG> Custom PNG icon sizes to generate. When set, the default icons are not generated
48+
--ios-color <IOS_COLOR> The background color of the iOS icon - string as defined in the W3C's CSS Color Module Level 4 <https://www.w3.org/TR/css-color-4/> [default: #fff]
49+
-h, --help Print help
50+
-V, --version Print version
51+
```
52+
53+
The **desktop** icons will be placed in your `src-tauri/icons` folder by default, where they will be included in your built app automatically. If you want to source your icons from a different location, you can edit this part of the `tauri.conf.json` file:
54+
55+
```json
56+
{
57+
"bundle": {
58+
"icon": [
59+
"icons/32x32.png",
60+
"icons/128x128.png",
61+
62+
"icons/icon.icns",
63+
"icons/icon.ico"
64+
]
65+
}
66+
}
67+
```
68+
69+
The **mobile** icons will be placed into the Xcode and Android Studio projects directly!
70+
71+
## Creating icons manually
72+
73+
If you prefer to build these icons yourself, for example if you want to have a simpler design for small sizes or because you don't want to depend on the CLI's internal image resizing, you must make sure your icons meet some requirements:
74+
75+
- `icon.icns`: The required layer sizes and names for the [`icns`] file are described [in the Tauri repo]
76+
- `icon.ico`: The [`ico`] file must include layers for 16, 24, 32, 48, 64 and 256 pixels. For an optimal display of the ICO image _in development_, the 32px layer should be the first layer.
77+
- `png`: The requirements for the png icons are: width == height, RGBA (RGB + Transparency), and 32bit per pixel (8bit per channel). Commonly expected sizes on desktop are 32, 128, 256, and 512 pixels. We recommend to at least match the output of `tauri icon`: `32x32.png`, `128x128.png`, `[email protected]`, and `icon.png`.
78+
79+
### Android
80+
81+
On Android you will need png icons with the same requirements but in different sizes. They will also need to be placed directly in the Android Studio project:
82+
83+
- `src-tauri/gen/android/app/src/main/res/`
84+
- `mipmap-hdpi/`
85+
- `ic_launcher.png` & `ic_launcher_round.png`: 49x49px
86+
- `ic_launcher_foreground.png`: 162x162px
87+
- `mipmap-mdpi/`
88+
- `ic_launcher.png` & `ic_launcher_round.png`: 48x48px
89+
- `ic_launcher_foreground.png`: 108x108px
90+
- `mipmap-xhdpi/`
91+
- `ic_launcher.png` & `ic_launcher_round.png`: 96x96px
92+
- `ic_launcher_foreground.png`: 216x216px
93+
- `mipmap-xxhdpi/`
94+
- `ic_launcher.png` & `ic_launcher_round.png`: 144x144px
95+
- `ic_launcher_foreground.png`: 324x324px
96+
- `mipmap-xxxhdpi/`
97+
- `ic_launcher.png` & `ic_launcher_round.png`: 192x192px
98+
- `ic_launcher_foreground.png`: 432x432px
99+
100+
If `tauri icon` cannot be used, we recommend checking out Android Studio's [Image Asset Studio] instead.
101+
102+
### iOS
103+
104+
On iOS you will need png icons with the same requirements but **without transparency** and in different sizes. They will also need to be placed directly in the Xcode project into `src-tauri/gen/apple/Assets.xcassets/AppIcon.appiconset/`. The following icons are expected:
105+
106+
- 20px in 1x, 2x, 3x, with an extra icon
107+
- 29px in 1x, 2x, 3x, with an extra icon
108+
- 40px in 1x, 2x, 3x, with an extra icon
109+
- 60px in 2x, 3x
110+
- 76px in 1x, 2x
111+
- 83.5px in 2x
112+
- 512px in 2x saved as `[email protected]`
113+
114+
The file names are in the format of `AppIcon-{size}x{size}@{scaling}{extra}.png`. For the 20px icons this means you need icons in sizes 20x20, 40x40 and 60x60 named as `[email protected]`, `[email protected]`, `[email protected]` and `2x` saved additionally as `[email protected]` ("extra icon").
115+
116+
[in the tauri repo]: https://github.com/tauri-apps/tauri/blob/1.x/tooling/cli/src/helpers/icns.json
117+
[`icns`]: https://en.wikipedia.org/wiki/Apple_Icon_Image_format
118+
[`ico`]: https://en.wikipedia.org/wiki/ICO_(file_format)
119+
[image asset studio]: https://developer.android.com/studio/write/create-app-icons

0 commit comments

Comments
 (0)