Namespace sap.ui.core.IconPoolModule: sap/ui/core/IconPool


The IconPool is a static class for retrieving or registering icons. It also provides helping methods for easier consumption of icons. There are already icons registered in IconPool, please use the Demo App named "Icon Explorer" to find the name of the icon.

In order to use the icon inside an existing control, please call sap.ui.core.IconPool.getIconURI and assign the URI to the control's property which supports icons. If you want to support both, icons and standard images in your own control, please use the static method sap.ui.core.IconPool.createControlByURI to either create an Icon in case the first argument is an icon-URL or another control which you define by providing it as the second argument.

Method Summary
sap.ui.core.IconPool.addIcon(iconName, collectionName, iconInfo)Register an additional icon to the sap.ui.core.IconPool.
sap.ui.core.IconPool.createControlByURI(setting, constructor)Creates an instance of sap.ui.core.Icon if the given URI is an icon URI, otherwise the given constructor is called.
sap.ui.core.IconPool.getIconCollectionNames()Returns all names of registered collections in IconPool
sap.ui.core.IconPool.getIconForMimeType(sMimeType)Returns the icon url based on the given mime type
sap.ui.core.IconPool.getIconInfo(iconName, collectionName?)Returns an info object for the icon with the given iconName and collectionName.
sap.ui.core.IconPool.getIconNames(collectionName)Returns all name of icons that are registerd under the given collection.
sap.ui.core.IconPool.getIconURI(iconName, collectionName?)Returns the URI of the icon in the pool which has the given iconName and collectionName.
sap.ui.core.IconPool.isIconURI(uri)Returns whether the given uri is an icon URI.
Method Detail
sap.ui.core.IconPool.addIcon(iconName, collectionName, iconInfo): object
Register an additional icon to the sap.ui.core.IconPool.
Parameters:
{string}iconName the name of the icon.
{string}collectionName the name of icon collection. The built in icons are with empty collectionName, so if additional icons need to be registered in IconPool, the collectionName can't be empty.
{object}iconInfo the icon info which contains the following properties:
{string}iconInfo.fontFamily is the name of the font when importing the font using @font-face in CSS
{string|string[]}iconInfo.content is the special hexadecimal code without the prefix, for example "e000" or several of them
{boolean}iconInfo.overWrite? indicates if already registered icons should be overwritten when the same name and collection are given. The built in icons can never be overwritten.
{boolean}iconInfo.suppressMirroring? indicates whether this icon should NOT be mirrored in RTL (right to left) mode.
{jQuery.sap.util.ResourceBundle}iconInfo.resourceBundle? ResourceBundle to be used for translation. Key format: "Icon.".
Returns:
{object} the info object of the registered icon which has the name, collection, uri, fontFamily, content and suppressMirroring properties.
sap.ui.core.IconPool.createControlByURI(setting, constructor): sap.ui.core.Control
Creates an instance of sap.ui.core.Icon if the given URI is an icon URI, otherwise the given constructor is called. The given URI is set to the src property of the control.
Parameters:
{string|object}setting contains the properties which will be used to instantiate the returned control. It should contain at least a property named src. If it's given with a string type, it will be taken as the value of src property.
{function}constructor the constructor function which is called when the given URI isn't an icon URI
Returns:
{sap.ui.core.Control} either an instance of sap.ui.core.Icon or instance created by calling the given constructor
sap.ui.core.IconPool.getIconCollectionNames(): array
Returns all names of registered collections in IconPool
Returns:
{array} An array contains all of the registered collections' names.
sap.ui.core.IconPool.getIconForMimeType(sMimeType): string
Returns the icon url based on the given mime type
Parameters:
{string}sMimeType the mime type of a file (e.g. "application/zip")
Since:
1.25.0
Returns:
{string} the icon url (e.g. "sap-icon://attachment-zip-file")
sap.ui.core.IconPool.getIconInfo(iconName, collectionName?): object
Returns an info object for the icon with the given iconName and collectionName.

Instead of giving name and collection, a complete icon-URI can be provided as iconName. The method will determine name and collection from the URI, see IconPool.isIconURI for details.

The returned info object has the following properties:

  • string: name Name of the icon
  • string: collection Name of the collection that contains the icon or undefined in case of the default collection
  • string: uri Icon URI that identifies the icon
  • string: fontFamily CSS font family to use for this icon
  • string: content Character sequence that represents the icon in the icon font
  • string: text Alternative text describing the icon (optional, might be empty)
  • boolean: suppressMirroring Whether the icon needs no mirroring in right-to-left mode
Parameters:
{string}iconName Name of the icon, must not be empty
{string}collectionName? Name of the icon collection; to access built-in icons, omit the collection name
Returns:
{object} Info object for the icon or undefined when the icon can't be found.
sap.ui.core.IconPool.getIconNames(collectionName): array
Returns all name of icons that are registerd under the given collection.
Parameters:
{string}collectionName the name of collection where icon names are retrieved.
Returns:
{array} An array contains all of the registered icon names under the given collection.
sap.ui.core.IconPool.getIconURI(iconName, collectionName?): string
Returns the URI of the icon in the pool which has the given iconName and collectionName.
Parameters:
{string}iconName Name of the icon, must not be empty
{string}collectionName? Name of the icon collection; to access built-in icons, omit the collection name
Returns:
{string} URI of the icon or undefined if the icon can't be found in the IconPool
sap.ui.core.IconPool.isIconURI(uri): boolean
Returns whether the given uri is an icon URI.

A string is an icon URI when it can be parsed as an URI and when it has one of the two forms

  • sap-icon://collectionName/iconName
  • sap-icon://iconName
where collectionName and iconName must be non-empty.
Parameters:
{string}uri The URI to check
Returns:
{boolean} Whether the URI matches the icon URI format