Fragment Specific Tags and Attributes Reference

Along with standard HTML, CSS, and JavaScript, you can use Liferay-specific tags and, since Liferay Portal 7.3 GA3 and Liferay DXP 7.3, attributes, to make editable sections or embed widgets in your fragment. Editable elements can be modified before publication, which means that you can create simple, reusable fragments that have identical formatting, but contain elements that are adaptable to the specific context.


Nesting editable elements inside of other editable elements in a fragment is not supported.

Page fragments have access to these types of liferay-specific tags and attributes that add these features:


When you start typing the name of a tag, the HTML editor provides auto-completion for lfr tags like editable elements and embeddable widgets.

The text or images you provide here are the default values for the fields. You may want to display them in the final version of the page, or you may want filler text that should be replaced before publishing the page.

All of these work together to help you create dynamic, reusable elements for building a site. For example, if you need a small text box with an image and link to provide a product description, you can create a fragment containing editable filler text, space for an editable image, the appropriate formatting, and an editable link. You can then add the fragment to multiple pages and define the image, text, and link for each product you need to describe.


IDs of editable elements must be unique. Do not change the ID after the page fragment has been added to a page. Changing the ID of an editable fragment after it’s been modified can cause the changes to be lost.

You can make a fragment even more dynamic by including a widget. Currently, portlets are the only embeddable types of widgets, but other options are planned.

The fragment editor provides autocomplete for fragment-specific tags.

This reference list the available editable tags and attributes along with examples of how to use them in your fragments.


Since Liferay Portal 7.3 GA3 and Liferay DXP 7.3, you can use data-lfr-editable* attributes to define elements as editable, rather than wrapping editable elements with lfr-editable tags. The old tags still work for backwards compatibility, but we recommend that you use the newer data attributes if you’re running Portal 7.3 GA3+ or Liferay DXP 7.3, as they are easier to write.

Making Text Editable

You can make fragment text editable by including the data-lfr-editable-type="text" attribute in the image element. The data-lfr-editable-id must be a unique ID, like this example:

<p data-lfr-editable-id="text1" data-lfr-editable-type="text">


All block elements and inline elements are supported for editable text.

For Liferay Portal 7.3 GA2 and below, use the syntax below. A unique ID is required to render the element properly:

<lfr-editable id="unique-id" type="text">
   This is editable text!

If you need formatting options like text or color styles, use rich-text:

<p data-lfr-editable-id="text1" data-lfr-editable-type="rich-text">


All block element tags are supported for editable Rich text.

For Liferay Portal 7.3 GA2 and below, use the syntax below:

<lfr-editable id="unique-id" type="rich-text">
   This is editable text that I can make bold or italic!


If you want to make text inside an HTML element editable, you must use the rich-text type. The text type strips HTML formatting out of the text before rendering.

Making Images Editable

Images use the same data-lfr-editable-type attribute as text, but with the image type, like this:


For Liferay Portal 7.3 GA2 and below, use this syntax:

<lfr-editable id="unique-id" type="image">
   <img src="...">

After you add the lfr-editable tag with the type image to a fragment, when you add that fragment to a page, you can then click on the editable image and configure the image source and other properties from the content page editor sidebar.

You have several options for defining an image on a content page.

Most images can be handled like this, but to add an editable background image you must add an additional property to set the background image ID, data-lfr-background-image-id. The background image ID is set in the main div for the fragment and is the same as your editable image ID.

<div data-lfr-background-image-id="unique-id">
   <lfr-editable id="unique-id" type="image">
      <img src="...">

Content mapping connects editable fields in your fragment with fields from an asset type like web content or blogs. For example, you can map an image field to display a preview image for a web content article. For more information on mapping fields, see Fragment Mapping Settings.

Creating Editable HTML

You can make general HTML elements editable as well by setting the data-lfr-editable-type attribute to html:

<article data-lfr-editable-id="text1" data-lfr-editable-type="html">

For Liferay Portal 7.3 GA2 and below, use this syntax:

<lfr-editable type="html" id="text1">

Including Widgets Within A Fragment

Each widget has a registered name and corresponding lfr-widget-[name] tag, which you must use to embed it in a fragment. For example, the Menu Display widget is registered as nav, so its tag is <lfr-widget-nav />. You can embed it in a block like this:

<div class="nav-widget">

These are the widgets that can be embedded and their accompanying tags:

Widget Name


DDL Display




Asset Publisher




Category Filter




Media Gallery


Menu Display


Polls Display


Related Assets


Site Map


Tag Cloud


Tag Filter


Web Content Display


RSS Publisher (Deprecated)




Enabling Embedding for Your Widget

If you have a custom widget that you want to embed in a fragment, you can configure that widget to be embeddable. To embed your widget, it must be an OSGi Component. Inside the @Component annotation for the portlet class you want to embed, add this property:


When you deploy your widget, it’s available to add. The name you specify in the property must be appended to the lfr-widget tag like this:



According to the W3C HTML standards, custom elements can’t be self-closing. Therefore, even though you can’t add anything between the opening and closing <lfr-widget...> tags, you can’t use the self-closing notation for the tag.

Localizing Fragment Configurations

Available: Liferay DXP/Portal 7.4+

You can localize fragment configuration for a page’s target language. For example, on a button fragment you can define one button type when the page language is en-US, and a different button type when the page language is es-ES. To localize a fragment configuration field, use the localizable attribute.


The localizable attribute is not available for fragment configuration fields where the configurationRole property is set to style.

In the following code excerpt, the button fragment configuration sets the localizable attribute to true for the fields section under fieldSets. The localizable attribute is set at the field level. In the example, there is only one buttonType field. If you have a fragment with multiple fields, you can set the localizable attribute for each one:

"fieldSets": [
    "fields": [
        "dataType": "string",
        "defaultValue": "primary",
        "label": "type",
        "name": "buttonType",
        "type": "select",
        "localizable": true,
        "typeOptions": {
          "validValues": [
              "value": "primary"
              "value": "secondary"
              "value": "link"
              "value": "outline-primary"
              "value": "outline-secondary"

You can use this sample code to change the button type depending on the page’s target language. In the following example, the Contact Us/Contacto button fragment sets the localizable attribute to true for the buttonType field. The example uses this attribute to configure the Primary button type when the page uses the en-US language (A) and the Outline Primary type when the page uses es-ES (B).

Localizable elements in the fragment show the flag icon under the General tab and support different configurations for different languages.


The flag icon under the fragment’s General settings indicates the configuration field as localizable.

Fragments with the localizable attribute that do not specify a custom configuration for a language use the default page language’s configuration.

Additional Information