Create a rendering variant

Last updated Thursday, April 26, 2018 in Sitecore Experience Accelerator for Designer, Developer
Keywords: Configuration, Layouts

SXA comes with a set of default renderings and rendering variants. Rendering variants are configurable adaptations of the default renderings. To encourage reusability, designers and front-end developers can also create new rendering variants. This gives authors more options in the way they present their content.

You can create your own variation of a rendering by adding a variant in the Content Editor.

To create a rendering variant:

  1. In the Content Editor, click the site and open the Presentation/Rendering Variants folder. This folder lists all the renderings that allow variants.


    To add a rendering to the folder, contact your Administrator.

  2. Right-click the rendering that you want to add the variant to, and then click Insert, Variant Definition.

    Go to Presentation, Rendering Variant, right-click the rendering.

  3. Enter a name and click OK.
  4. In the Variant Details section, specify information in the following fields:
    • Css Class: specify the class name for the variant in the HTML.
    • Item CSS class: specify the CSS class for list items. For example, for variants of PageList, LinkList, FileList, and Navigation renderings.
    • Field used as link target: provide the field name of the target item. This class is added to the list and navigation items markup (li HTML element). This link is used to override all links when the Is link, Is prefix link, or Is suffix link check boxes are selected.
    • Allowed in templates: specify the pages that the variant is available for. Click the relevant page template, click the right arrow to move it to the list of selected items, and then click Save. If there are no templates selected, the variant is available for all pages.
  5. Optionally, in the Appearance section, you can add a thumbnail image for the variant. This image will appear in the variants drop-down box and can help content editor select the best variant for their purpose.

    Content Editor

    Experience Editor

    Add a thumbnail images.

    In the Experience Editor, select the rendering variant.


    Rendering variants without a thumbnail display with their name only.

    Rendering variants without a thumbnail display with their name only.

  6. To define the fields that will be displayed, you can add child items to the rendering variant, right-click the variant, click Insert, and then click the relevant item.

    Picture 1

    These are the child items available for a rendering variant:

    • Date: displays data and time in custom format. To be able to display date and time in custom format you have to use the Date item. This item is similar to the Field item but has an additional field: "Date format" that allows you to choose a date and time format. Like the Field item, the Date item can be used as fallback item and can have its own fall back items defined.


      The fields and variant details are described in a table below.

    • Edit Frame: variant item that can be used in the Edit mode.
    • Field: displays field name and other field values.
    • HTML Tag: enables users to render HTML self-closing tags.
    • Model: displays properties from the current Model. The SXA renderings model inherits from Sitecore.XA.Foundation.Mvc.Models.RenderingModelBase. In the Property path field, you can enter the path to the property that you want to display.
    • Placeholder: renders a placeholder that enables users to add additional renderings. If you want the user to be able to switch context for the renderings inside this placeholder, go to the VariantDetails section and select the Switch component context to currently rendered item checkbox.

      Picture 2

    • Reference: displays field from referenced item. If you want to display a field from a referenced item, you can define this field in the PassThroughField. You can use this variant field for the following fields: LinkField (GeneralLink, DropLink), FileField (File), ImageField (Image), and ReferenceField (Droptree). Reference items can contain have another reference item as its child item. This can be convenient when you want to create a tree of reference items and display fields from items which are referenced in referenced items.
    • Responsive Image: enables to define the default size as well as the allowed sizes and width of images. Making your images responsive means that your browser serves a different sized version of that image based on the size of the image on your page and the screen resolution. The values entered in the Variant Details section will be combined in a srcset attribute. The values in the following screenshot will generate the following img tag:

      Picture 6

    <img src="/-/media/Project/Tenant/Site/26056130_2115225655366272_5152181870065454436_n/MyImage.JPEG?w=400&amp;hash=C54AFF8A74289E7B0A776137DFF1D4F89DDEFF93" alt="Simple description of the image" sizes="(max-width: 320px) 280px, (max-width: 480px) 440px, 800px" srcset="/-/media/Project/Tenant/Site/26056130_2115225655366272_5152181870065454436_n/MyImage.JPEG?w=280&amp;hash=DB3A5BEB52094FC6C547F04211070DE715F458D3 280w,/-/media/Project/Tenant/Site/26056130_2115225655366272_5152181870065454436_n/MyImage.JPEG?w=440&amp;hash=247F0C11B22A5339E5913F9C4EC52361D1D2A1F2 440w,/-/media/Project/Tenant/Site/26056130_2115225655366272_5152181870065454436_n/MyImage.JPEG?w=800&amp;hash=D10309E3D24FF417E3194419240075419EF353B8 800w">
    • Section: used to create groups. Section contains fields such as Tag (to create wrapping element for the section, for example "div") and CssClass (to add a css class to the wrapping tag). You can nest Section items to create more complex variant structure.
    • Template: allows user to define NVelocity template which will be used to render part of the HTML. The getVelocityTemplateRenderers pipeline can be used to add a custom renderer that later on can be used in the NVelocity template.


      NVelocity is a .Net-based template engine. It permits developers to use the simple yet powerful template language to reference objects defined in .Net code.

    • Text: displays text. Used to render custom string of for example a description. You can use the following fields: Text, Tag (define additional tag that will wrap text), CssClass (the css class that will be added to the tag), IsLink (if selected then custom text will be additionally wrapped by hyper link to the current item).
    • Token: SXA supports tokens $id (renders id of the item), $size (formats size of attached asset), $name (renders name if the item), and $FileTypeIcon (renders span with css classed equal to the file extension). The custom pipeline resolveVariantTokens can be used to extend the set of variant tokens.
    • Query: allows to specify a query that will be will be run on current context item. This enables you to query child items or use SXA tokens. For example, if you want the rendering variant to display only for the child items of a certain template. You must start your query with query and then use standard Sitecore query syntax. You can combine Sitecore queries with SXA tokens such as $home and $site.

    Depending on the item you add, you can set the following fields:


    Variant details


    HTML tag in which the field content will be rendered. For example: div

    If left empty field content will remain unwrapped.

    Field name

    Name of the field current item.


    Adds string value as a prefix.


    Adds string value as a suffix.

    Is link

    Select to have hyperlinks that wrap the field content.

    Is prefix link

    Select to wrap prefix in the same link which you use for the field content.

    Is suffix link

    Select to wrap the suffix with a hyperlink.

    Is download link

    Select to have a hyperlink with a download attribute.

    Css class

    Adds Css class to the tag.

    Is editable

    Select to edit rendered field.

    Date format

    Determines the date format.

    Render if empty

    Select to render empty element when the field is empty.

    Pass through field

    Defines the name of the field from the nested item.


    The text to render.


    Define the NVelocity template that renders part of the component variant HTML. You can use the following objects:

    $item: access to the current item ($item.Name displays current item name).

    $dateTool.Format(date, format): formats date and time values.

    $numberTool.Format(number, format): formats numbers.

    $geospatial: in case of geospatial search ($geospatial.Distance) will show distance to certain point of interest).


    Use special tokens to format certain field values. Supported tokens are:

    $Size: displays size of a file depending on size unit.

    $FileTypeIcon: displays icon depending on file extension.


    Determines the query that will be run on the current context item. For example:

    To get all child items:


    To get all items of Page template from under the current item:


    To get all items of Page template from under Home item of the current site:


    Maximum number of results

    Enter a number to limit the number of items returned.

    Property path

    In the Property path field, you can enter the path to the property that you want to display. For example, Item.Paths.Path will access Item property from Model, then dig deeper and access the Paths property and then the Path string.




Send feedback about the documentation to