Skip to main content

SitecoreAI · Tutorial

Adding Rendering Parameters & Variant Styling to a Component

Give content authors a UI for picking styling variants instead of hardcoding classes — set up entirely in the template tree.

gavAusWeb2 min read

Goal: give content authors a UI to pick styling variants for a component, instead of hardcoding classes. This is the step that trips up most front-end devs moving into XMC because it lives entirely in the template tree, not in code.

Set up the parameters templateLink to this section

  1. Step 1: Create the Rendering Parameters template

    Go to Templates › Project › [site] › [Component]. Add a new folder called 'Rendering Parameters', then create a template inside it with the same name as your component.

  2. Step 2: Give it Standard Values

    Select the new template and give it Standard Values.

  3. Step 3: Add the styling fields

    Open the template, name the section 'Styling', and add one field per variant option — a Droplist for a fixed set of choices, e.g. ContentAlign, Padding, Margin.

    Point each field's Source at the settings item that holds the valid values, using the query: syntax, e.g. query:$siteMedia.

  4. Step 4: Set the base template

    From the Content tab of your Rendering Parameters template, set the Base template to Base Rendering Parameters (under Foundation › Experience Accelerator › Presentation › Rendering Parameters). This wires in the standard fields every rendering parameter template needs.

  5. Step 5: Attach it to the rendering

    Go to Layout › Renderings › [site] › [component], and set 'Parameters Template' to the template you just built.