Skip to content

Commit 54f5399

Browse files
Merge pull request #7439 from bszyman/icons
Icons
2 parents 7731f98 + 216a93d commit 54f5399

File tree

1 file changed

+23
-37
lines changed
  • 16/umbraco-cms/customizing/extending-overview/extension-types

1 file changed

+23
-37
lines changed
Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,64 @@
11
---
2-
description: Learn how to append and use Icons.
2+
description: Create custom icon sets for use across the Umbraco backoffice.
33
---
44

55
# Icons
66

7-
This article describes how to add and use more icons in your UI.
8-
9-
{% hint style="warning" %}
10-
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
11-
{% endhint %}
7+
Umbraco extension authors can create custom icon sets for use across the Umbraco backoffice using an extension type called `icons`.
128

139
## Register a new set of icons
1410

15-
New icons can be added via an extension type called `icons`.
16-
17-
You must add a new manifest to the Extension API to register icons. The manifest can be added through the `umbraco-package.json` file as shown in the snippet below.
11+
Icons must be registered in a manifest using the Extension API. The manifest can be added through the `umbraco-package.json` file, as shown below.
1812

1913
{% code title="umbraco-package.json" %}
20-
2114
```json
2215
{
23-
"name": "MyPackage",
24-
"extensions": [
25-
{
26-
"type": "icons",
27-
"alias": "MyPackage.Icons.Unicorn",
28-
"name": "MyPackage Unicorn Icons",
29-
"js": "/App_Plugins/MyPackage/Icons/icons.js"
30-
}
31-
]
16+
"$schema": "../../umbraco-package-schema.json",
17+
"name": "My Package",
18+
"version": "0.1.0",
19+
"extensions": [
20+
{
21+
"type": "icons",
22+
"alias": "My.Icons.Unicorn",
23+
"name": "My Unicorn Icons",
24+
"js": "/App_Plugins/MyPackage/Icons/icons.js"
25+
}
26+
]
3227
}
3328
```
34-
3529
{% endcode %}
3630

37-
The file set in the `js` field holds the details about your Icons. The file should resemble the following:
31+
The file set in the `js` field contains the details of your icons. These definitions should resemble the following:
3832

3933
{% code title="icons.js" %}
40-
41-
```typescript
34+
```javascript
4235
export default [
4336
{
44-
name: "myPackage-unicorn",
37+
name: "my-unicorn",
4538
path: () => import("./icon-unicorn.js"),
4639
},
4740
{
48-
name: "myPackage-giraffe",
41+
name: "my-giraffe",
4942
path: () => import("./icon-giraffe.js"),
5043
}
5144
]
5245
```
53-
5446
{% endcode %}
5547

56-
The icon name needs to be prefixed to avoid collision with other icons.
48+
Prefix each icon name to avoid collisions with other icons.
5749

58-
Each icon must define a path, either as a string or a dynamic import as shown above. This file must be a JavaScript file containing a default export of an SVG string. See an example of this in the code snippet below.
50+
Each icon must define a path, either as a string or a dynamic import as shown above. This file must be a JavaScript file containing a default export of an SVG string. See an example below:
5951

6052
{% code title="icon-unicorn.js" %}
61-
62-
```typescript
53+
```javascript
6354
export default `<svg ...></svg>`;
6455
```
65-
6656
{% endcode %}
6757

6858
### Using Icons in your UI
6959

70-
The `umb-icon` element is automatically able to consume any registered icon.
71-
72-
The following example shows how to make a button using the above-registered icon.
60+
The `umb-icon` element can automatically consume any registered icon.
7361

7462
```html
75-
<uui-button compact label="Make the unicorn dance">
76-
<umb-icon name="myPackage-unicorn"></umb-icon>
77-
</uui-button>
63+
<umb-icon name="my-unicorn"></umb-icon>
7864
```

0 commit comments

Comments
 (0)