Raman Gupta
Raman Gupta

Reputation: 239

tooltip background color change and font styles of tooltip text in primefaces

I am trying to see some features availability in prime-faces..... I wanted to know if there are any font styles and background color change functionality available in tool-tip in prime-faces...

Please let me know.

here is the sample code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <title>Tool Tip Customization</title>
    </h:head>
    <h:body>

    <h:panelGrid columns="3" cellpadding="5">  

    <h:outputText value="Focus/Blur: " />  
    <p:inputText id="focus" title="This tooltip is displayed when input gets the focus"/>  
    <p:tooltip for="focus" showEvent="focus" hideEvent="blur" />  

    <h:outputText value="Fade: " />  
    <h:outputLink id="fade" value="#">  
        <h:outputText value="Fade Effect" />  
    </h:outputLink>  
    <p:tooltip for="fade" value="Fade effect is used by default" showEffect="fade" hideEffect="fade" />  

    <h:outputText value="Slide: " />  
    <h:outputLink id="slide" value="#">  
        <h:outputText value="Slide Effect" />  
    </h:outputLink>  
    <p:tooltip for="slide" value="This tooltip uses slide effect for the animation" showEffect="slide" hideEffect="slide" />  

    <h:outputText value="Clip/Explode: " />  
    <h:outputLink id="grow" value="#">  
        <h:outputText value="Clip/Explode Effects" />  
    </h:outputLink>  
    <p:tooltip for="grow" value="This tooltip uses clip/explode effects for the animation" showEffect="clip" hideEffect="explode" />  

    <h:outputText value="Content:  " />  
    <h:outputLink id="lnk" value="#">  
        <h:outputText value="PrimeFaces Users" />  
    </h:outputLink>  
    <p:tooltip for="lnk">  
        <p:graphicImage value="C:\raman\AMAP\POC\primefaces\JSF2.0HelloWorld\WebContent\images\Users.gif" />  
    </p:tooltip>  

</h:panelGrid>  
</h:body>
</html>

Upvotes: 2

Views: 21335

Answers (3)

Giovanni Perea
Giovanni Perea

Reputation: 358

try to override with the following class

.ui-tooltip .ui-tooltip-text {
    background-color: red;
    color: #fff;
}

Upvotes: 0

matof
matof

Reputation: 119

If you want to set styles for all tooltips globally you can use class ui-tooltip. For example like this:

.ui-tooltip {
    border: 1px solid #ccc;
    box-shadow: 0 0 10px 0 #ddd;
    -moz-box-shadow: 0 0 10px 0 #ddd;
    -webkit-box-shadow: 0 0 10px 0 #ddd;
    color: #666;
    background: #f8f8f8;
}

As written in PrimeFaces Userʼs Guide: Tooltip has only .ui-tooltip as a style class and is styled with global skinning selectors, see main skinning section for more information.

Upvotes: 6

Matt Handy
Matt Handy

Reputation: 30025

The Primefaces tooltip component has styleand styleClass attributes:

Quick example to change font color:

<p:tooltip for="slide" value="Text" 
           style="color : red; background-color : yellow"/>  

Upvotes: 3

Related Questions