blockly > Block > getIcon
Block.getIcon() method
Signature:
getIcon<T extends IIcon>(type: IconType<T> | string): T | undefined;
Parameters
Parameter |
Type |
Description |
type |
IconType<T> | string |
The type of the icon to retrieve. Prefer passing an IconType for proper type checking when using typescript. |
Returns:
T | undefined
The icon with the given type if it exists on the block, undefined otherwise.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[null,null,["Last updated 2024-09-18 UTC."],[[["The `Block.getIcon()` method retrieves a specific icon associated with a block, if available."],["It accepts an `IconType` or a string representing the icon type as input."],["The method returns the requested icon if found, otherwise it returns `undefined`."]]],["The `Block.getIcon()` method retrieves an icon associated with a block. It accepts a parameter `type`, which specifies the icon type, preferably as an `IconType` for TypeScript type checking, or as a string. The method returns the icon of the specified type if it exists on the block, otherwise, it returns undefined. This allows users to access a specific icon from a Block by providing its corresponding type.\n"]]