I managed to create a custom rendering in SXA by inheriting my controller from the StandardController (and some other things). But now I would like to create a component that has the ability to work with variants. I saw that there is a VariantsController, so I assume that my first step is to use that as base for my custom controller, but what are the other steps I need to take to have 2 variants of my rendering? And what are the options in my view with these variants - what can be altered?

1 Answer 1


Yes, you should inherit from VariantsController. It's very small and all what it's doing is providing VariantsRepository (in SXA almost all of logic is placed inside of repositories). It got all what you need to enable your rendering using Rendering Variants.

So the steps you be as follow:

  1. Your rendering parameters template should inherit from IComponentVariant enter image description here
  2. Your repository should inherit from VariantsRepository
  3. Your model which you push to your view should inherit from VariantsRenderingModel
  4. Render content using SXA helpers @Html.RenderingVariants().RenderVariant(). You can take a look at views of Page Content or Title renderings which are quite simple.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.