+ Start a Discussion
chinni dchinni d 

what are vf component and whendo we use them?

Dutta SouravDutta Sourav
Hi Chinni,

In our projects, many times we develop codes which are required again and again. So instead of repeating same code again and again, we can create visualforce component. In other words, visualforce component allows us to create reusable component.

To Create VF Components,
Go to Setup -> Develop -> Visualforce Components and Create

Warm Regards,
Amit Chaudhary 8Amit Chaudhary 8

A custom Visualforce component. All custom component definitions must be wrapped inside a single <apex:component> tag.

This component supports HTML pass-through attributes using the "html-" prefix. Pass-through attributes are attached to the generated container tag, <div> or <span>, depending on the layout attribute.
<!-- Page: -->


    <c:myComponent myValue="My component's value" borderColor="red" />


 <!-- Component:myComponent -->


    <apex:attribute name="myValue" description="This is the value for the component."

        type="String" required="true"/>

    <apex:attribute name="borderColor" description="This is color for the border."

        type="String" required="true"/>

    <h1 style="border:{!borderColor}">

        <apex:outputText value="{!myValue}"/>



Please let us know if this will help you

Amit Chaudhary