Font Awesome"

From Documentation
(Created page with "{{ZKDevelopersReferencePageHeader}} = Font Awesome Bundled = {{versionSince| 7.0.0}} Starting from ZK 7.0.0 integrates [https://fontawesomelib.com/releases/4.0.1/list/all/in...")
 
Line 87: Line 87:
  
 
<source lang="xml" highlight="2">
 
<source lang="xml" highlight="2">
<window>
 
 
     <button iconSclass="glyphicon glyphicon-envelope" />
 
     <button iconSclass="glyphicon glyphicon-envelope" />
</window>
 
 
</source>
 
</source>
  
Line 95: Line 93:
 
Moreover, the final width of icons might not be the same. To make the width of icons always be fixed, add <code>z-icon-fw</code>.
 
Moreover, the final width of icons might not be the same. To make the width of icons always be fixed, add <code>z-icon-fw</code>.
  
<source lang="xml" highlight="2, 3">
+
<source lang="xml">
<window hflex="min">
 
 
     <button iconSclass="z-icon-fw z-icon-home" />
 
     <button iconSclass="z-icon-fw z-icon-home" />
 
     <button iconSclass="z-icon-fw z-icon-bell z-icon-spin" />
 
     <button iconSclass="z-icon-fw z-icon-bell z-icon-spin" />
</window>
 
 
</source>
 
</source>
 
{{ZKDevelopersReferencePageFooter}}
 
{{ZKDevelopersReferencePageFooter}}

Revision as of 07:37, 6 March 2024

Font Awesome Bundled

Since 7.0.0

Starting from ZK 7.0.0 integrates Font Awesome 4.0.1 with the prefix z-icon. You don't need to manually include Font Awesome CSS because it's already packaged with ZK jar.

Basic Usage

To use it, just specify the iconSclass attribute. For a complete list of icons, please refer to FontAwesome Cheatsheet.

For example, to add a home icon on a Button,

    <button iconSclass="z-icon-home" />

If you want to use other Font Awesome functions such as the animation icon, you can include the external Font Awesome CSS link and add the CSS class to iconSclass. For example,

<?link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.1/css/font-awesome.css" rel="stylesheet"?>
<window>
    <button iconSclass="z-icon-bell fa-spin" />
    <button iconSclass="z-icon-home fa-2x fa-rotate-90" />
</window>

Since 8.0.0

ZK 8.0.0 integrates Font Awesome 4.3.0. Also, with ZK 8 there is no need to include an external font awesome CSS link to use an animation icon. Therefore the example above becomes

<window>
    <button iconSclass="z-icon-bell z-icon-spin" />
    <button iconSclass="z-icon-home z-icon-2x z-icon-rotate-90" />
</window>

Since 8.5.2

ZK 8.5.2 integrates Font Awesome 4.7.0.

Since 10.0.0

ZK 10.0.0 integrates Font Awesome 6.4.2 free icons and supports both Font Awesome 4 syntax and Font Awesome 6 syntax with styles specified:

<window>
    <!--Font Awesome 4 syntax-->
    <button iconSclass="z-icon-bell" />
    <!--Font Awesome 6 syntax-->
    <button iconSclass="z-icon-bell z-icon-solid" />
    <button iconSclass="z-icon-bell z-icon-regular" />
</window>


IconTooltip

Since 10.0.0 The iconTooltip attribute is introduced for adding a tooltip to an icon.

    <button iconSclass="z-icon-home" iconTooltip="home"/>

Multiple icons and tooltips

Since 10.0.0 One LabelImageElement can have multiple icons and tooltips set using Java API:

    e.setIconSclasses(new String[] {"z-icon-home", "z-icon-podcast"});
    e.setIconTooltips(new String[] {"tooltip1", "tooltip2"});

Please note that this is only supported through Java API but not Zul attributes.

Not Supported Usages

The following usages mentioned in Font Awesome official document are not supported:

  • Duotone
  • Stacking icons
  • Layering Text & Counters
  • Power Transforms

Use Other Icons

The iconSclass not only applies to font awesome icons ("z-icon-" classes): Any css class can be applied to customize. Notice you need to manually include related CSS or font file. For example, the bootstrap glyphicons can be used here too:

    <button iconSclass="glyphicon glyphicon-envelope" />

Since the web font is loaded after the character is being displayed if there is no cache, ZK doesn't know if the web font is ready when initializing. Therefore using hflex="min" with iconSclass may not get the desired result. Moreover, the final width of icons might not be the same. To make the width of icons always be fixed, add z-icon-fw.

    <button iconSclass="z-icon-fw z-icon-home" />
    <button iconSclass="z-icon-fw z-icon-bell z-icon-spin" />


Last Update : 2024/03/06

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.