Skip to content

Commit

Permalink
feat: Allow changing the icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur- committed Apr 21, 2023
1 parent d269bea commit 30fd836
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,40 @@ public Icon(String icon) {
* the icon name
*/
public Icon(String collection, String icon) {
setIcon(collection, icon);
}

/**
* Sets the icon to the given icon from the vaadin-icons collection.
*
* @param icon
* the icon name
*/
public void setIcon(String icon) {
setIcon(ICON_COLLECTION_NAME, icon);
}

/**
* Sets the icon to the given {@code icon} from the given
* {@code collection}.
*
* If you want to use a custom {@code <vaadin-iconset>} -based icon set, you
* also need to add a dependency and an import for it, example:
*
* <pre>
* <code>
* &#64;NpmPackage(value = "custom-icons", version = "1.0.0")
* &#64;JsModule("custom-icons/iconset.js")
* public class MyView extends Div {
* </code>
* </pre>
*
* @param collection
* the icon collection
* @param icon
* the icon name
*/
public void setIcon(String collection, String icon) {
getElement().setAttribute(ICON_ATTRIBUTE_NAME, collection + ':' + icon);
}

Expand Down

0 comments on commit 30fd836

Please sign in to comment.