-
Notifications
You must be signed in to change notification settings - Fork 811
Icons #7439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Icons #7439
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
60 changes: 23 additions & 37 deletions
60
16/umbraco-cms/customizing/extending-overview/extension-types/icons.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,78 +1,64 @@ | ||
| --- | ||
| description: Learn how to append and use Icons. | ||
| description: Create custom icon sets for use across the Umbraco backoffice. | ||
| --- | ||
|
|
||
| # Icons | ||
|
|
||
| This article describes how to add and use more icons in your UI. | ||
|
|
||
| {% hint style="warning" %} | ||
| 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. | ||
| {% endhint %} | ||
| Umbraco extension authors can create custom icon sets for use across the Umbraco backoffice using an extension type called `icons`. | ||
|
|
||
| ## Register a new set of icons | ||
|
|
||
| New icons can be added via an extension type called `icons`. | ||
|
|
||
| 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. | ||
| 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. | ||
|
|
||
| {% code title="umbraco-package.json" %} | ||
|
|
||
| ```json | ||
| { | ||
| "name": "MyPackage", | ||
| "extensions": [ | ||
| { | ||
| "type": "icons", | ||
| "alias": "MyPackage.Icons.Unicorn", | ||
| "name": "MyPackage Unicorn Icons", | ||
| "js": "/App_Plugins/MyPackage/Icons/icons.js" | ||
| } | ||
| ] | ||
| "$schema": "../../umbraco-package-schema.json", | ||
| "name": "My Package", | ||
| "version": "0.1.0", | ||
| "extensions": [ | ||
| { | ||
| "type": "icons", | ||
| "alias": "My.Icons.Unicorn", | ||
| "name": "My Unicorn Icons", | ||
| "js": "/App_Plugins/MyPackage/Icons/icons.js" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| {% endcode %} | ||
|
|
||
| The file set in the `js` field holds the details about your Icons. The file should resemble the following: | ||
| The file set in the `js` field contains the details of your icons. These definitions should resemble the following: | ||
|
|
||
| {% code title="icons.js" %} | ||
|
|
||
| ```typescript | ||
| ```javascript | ||
| export default [ | ||
| { | ||
| name: "myPackage-unicorn", | ||
| name: "my-unicorn", | ||
| path: () => import("./icon-unicorn.js"), | ||
| }, | ||
| { | ||
| name: "myPackage-giraffe", | ||
| name: "my-giraffe", | ||
| path: () => import("./icon-giraffe.js"), | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| {% endcode %} | ||
|
|
||
| The icon name needs to be prefixed to avoid collision with other icons. | ||
| Prefix each icon name to avoid collisions with other icons. | ||
|
|
||
| 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. | ||
| 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: | ||
|
|
||
| {% code title="icon-unicorn.js" %} | ||
|
|
||
| ```typescript | ||
| ```javascript | ||
| export default `<svg ...></svg>`; | ||
| ``` | ||
|
|
||
| {% endcode %} | ||
|
|
||
| ### Using Icons in your UI | ||
|
|
||
| The `umb-icon` element is automatically able to consume any registered icon. | ||
|
|
||
| The following example shows how to make a button using the above-registered icon. | ||
| The `umb-icon` element can automatically consume any registered icon. | ||
|
|
||
| ```html | ||
| <uui-button compact label="Make the unicorn dance"> | ||
| <umb-icon name="myPackage-unicorn"></umb-icon> | ||
| </uui-button> | ||
| <umb-icon name="my-unicorn"></umb-icon> | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.