Add an image or icon to primefaces tab header

arkantos picture arkantos · Jan 23, 2012 · Viewed 26.4k times · Source

im trying to use an image /icon on a tab header instead of text title(or may using both of them), i was testing using titleStyleClass seting an image background but doesnt work

my primefaces tab:

 <p:tab titleStyleClass="tCliente" title="Vehiculo">

My css style

 .tCliente 

 {     
   background-image: url(../images/logo_tropidatos.gif);
 }

Thanks for your help :D

Answer

sabadow picture sabadow · Aug 9, 2013

On PrimeFaces 3.0 and newer you can add a facet to override title on tabs:

<p:tabView>
    <p:tab>
        <!-- overrides title on tab-->
        <f:facet name="title">
               <h:outputText value="tab title"/>
               <p:graphicImage value="/resources/images/icon.png"/>
            </f:facet>

        <h:panelGrid>
            <!-- tab content -->
        </h:panelGrid>
    </p:tab>    
</p:tabView>

Hope it helps.