Skip to content

How to create rendering variant in Sitecore SXA?

Rendering Variants in Sitecore Experience Accelerator (SXA) allow you to create different HTML output for a rendering without changing the rendering’s view. Here’s how to create a Rendering Variant:

  1. Open Content Editor:  Start by opening the Content Editor in Sitecore.
  2. Navigate to the Rendering Variants:  Navigate to your site’s presentation rendering variants. The path will be something like `/sitecore/content/{Your Tenant}/{Your Site}/Presentation/Rendering Variants`.
  3. Select the Rendering:  Inside the Rendering Variants folder, you’ll see a list of all the renderings that support Rendering Variants. Select the rendering for which you want to create a new variant.
  4. Create a New Variant:  Once you’ve selected the rendering, in the Home tab of the Content Editor ribbon, click `Insert` from template, then `Rendering Variant Definition` to create a new variant.
  5. Name the Variant:  You will be asked to enter a name for the variant. Choose a name that clearly describes what this variant will do.
  6. Add Variant Fields:  Now you can add fields to the variant. These fields control the HTML structure of the variant. Right-click on the variant and select `Insert` > `Variant Field`. Each Variant Field will correspond to a field on the item that the rendering is displaying. Enter the name of the field in the Field Name property of the Variant Field.
  7. Customize the Variant:  You can further customize the variant by adding more fields or other elements like `Variant Section`, `Variant Template`, `Variant Text`, `Variant Date`, etc. You can also control the HTML markup around each field by setting the Tag property on the Variant Field.
  8. Save Changes:  After adding and configuring all the necessary fields, save your changes.

Now, when you add the rendering to a page in the Experience Editor, you can select this variant from the Variant dropdown in the rendering’s toolbar. The rendering will display the content as you have defined in your new variant.

Remember, you can create as many Rendering Variants as you need for each rendering, giving you a lot of flexibility in how you display content.

Share this post on social!

Leave a Reply

Your email address will not be published. Required fields are marked *