Custom Templates

Build fully custom consent banners with your own HTML and CSS. Templates use Mustache syntax for dynamic content: text wrapped in {{double braces}} gets replaced with real values (titles, button labels, descriptions) when the banner is shown to a visitor.

Custom templates are available on Pro (up to 5 templates) and Business (up to 20 templates) plans. Manage templates in the My Templates section of your dashboard.

Getting started

The easiest way to create a custom template is to start from an existing one. Go to Templates in your dashboard, click Duplicate on any system template, then edit the HTML and CSS in the built-in editor. Save your changes and use the preview to check how it looks.

Template structure

Each template has four parts, edited in separate tabs:

  • Banner HTML: the main consent banner markup
  • Banner CSS: styles for the banner
  • Prefs HTML: the preferences/settings panel where visitors can toggle individual cookie categories
  • Prefs CSS: styles for the preferences panel

Banner and preferences are rendered independently. The banner is shown first; the preferences panel opens when the visitor clicks the customize button.

Mustache variables

These variables are replaced with localized text from your site configuration. Most use double braces {{variable}}, which safely converts special characters. Description fields and the watermark use triple braces {{{variable}}} because they may contain HTML formatting from Markdown.

Variable Description
{{opt_in_title}}Opt-in banner title
{{{opt_in_description}}}Opt-in banner description. May contain HTML from Markdown.
{{accept_text}}Accept button text
{{reject_text}}Reject button text
{{customize_text}}Preferences/customize button text
{{save_text}}Save button text
{{opt_out_title}}Opt-out banner title
{{{opt_out_description}}}Opt-out banner description. May contain HTML from Markdown.
{{opt_out_do_not_sell_text}}"Do Not Sell" button text
{{notice_title}}Notice-only title
{{{notice_description}}}Notice-only description. May contain HTML from Markdown.
{{notice_button}}Notice acknowledge button text
{{cookie_policy_url}}Cookie policy URL
{{privacy_policy_url}}Privacy policy URL
{{cookie_policy_text}}Cookie policy link text
{{privacy_policy_text}}Privacy policy link text
{{prefs_title}}Preferences panel title
{{{preferences_description}}}Preferences panel description. May contain HTML from Markdown.
{{{watermark_html}}} LiteConsent branding (triple braces = unescaped HTML)

If you accidentally use double braces for a description field, LiteConsent will auto-correct them to triple braces when saving. Still, it is best to use triple braces from the start to keep your template clear.

Sections and conditionals

Sections control which parts of the template render based on the visitor's jurisdiction or your configuration. Use {{#section}}...{{/section}} to show content when a condition is true. Use {{^section}}...{{/section}} (with ^ instead of #) to show content when a condition is NOT true.

Jurisdiction sections

Section Renders when
{{#opt_in}}...{{/opt_in}}Visitor is in an opt-in jurisdiction (GDPR, LGPD, etc.)
{{#opt_out}}...{{/opt_out}}Visitor is in an opt-out jurisdiction (US state privacy, etc.)
{{#notice}}...{{/notice}}Visitor is in a notice-only jurisdiction

Do not remove jurisdiction sections

These sections ensure your banner adapts to the visitor's location. Without them, all visitors see the same banner regardless of their region, which may violate GDPR, CCPA, or other privacy regulations. GDPR requires explicit opt-in consent with reject and customize options. CCPA requires a "Do Not Sell" option. Always keep all three jurisdiction sections in your template.

Conditional sections

Section Renders when
{{#cookie_policy_url}}...{{/cookie_policy_url}}Cookie policy URL is configured
{{#privacy_policy_url}}...{{/privacy_policy_url}}Privacy policy URL is configured
{{#has_policy_links}}...{{/has_policy_links}}Either policy URL is configured
{{#preferences_description}}...{{/preferences_description}}Preferences description is set

Loops

Section Description
{{#categories}}...{{/categories}}Loop over cookie categories (used in prefs panel)
{{#cookies}}...{{/cookies}}Loop over cookies within a category

Category and cookie fields

Inside the {{#categories}} loop, these fields are available:

Field Description
{{name}}Category name (e.g. "Analytics")
{{slug}}Category identifier, e.g. analytics, marketing. Use in data-lc-toggle attributes.
{{description}}Category description
{{#is_required}}...{{/is_required}}Section for required (essential) categories
{{^is_required}}...{{/is_required}}Section for optional categories (inverted)

Inside the {{#cookies}} loop (nested within a category):

Field Description
{{name}}Cookie name
{{domain}}Cookie domain
{{description}}Cookie description
{{duration}}Cookie duration/expiry
{{provider}}Cookie provider

data-lc-* attributes

These HTML attributes wire up banner behavior. Add them to buttons, links, or other interactive elements.

Actions

Attribute Effect
data-lc-action="accept_all"Accept all cookie categories
data-lc-action="reject_all"Reject all optional categories (necessary only)
data-lc-action="save"Save the current toggle selections (preferences panel)
data-lc-action="preferences"Open the preferences panel
data-lc-action="close"Close the banner or go back from preferences
data-lc-action="do_not_sell"Opt out of sale/sharing (CCPA)
data-lc-action="slug1,slug2"Accept only the listed categories by their slugs, comma-separated (e.g. analytics,marketing)

Toggles

Attribute Effect
data-lc-toggle="{{slug}}"Checkbox/toggle for a cookie category. Use on <input type="checkbox"> inside the categories loop.
data-lc-hide-on-dirtyElement is hidden when any toggle state changes
data-lc-show-on-dirtyElement is shown when any toggle state changes (useful for a "Save" button that only appears after changes)

CSS variables

LiteConsent injects CSS custom properties based on your site's design settings. Use these in your template CSS to stay consistent with the dashboard color/font configuration.

Variable Description
--lc-bgBackground color
--lc-textText color
--lc-acceptAccept button color
--lc-rejectReject/secondary button color
--lc-accept-textAccept button text color
--lc-reject-textReject button text color
--lc-accept-hoverAccept button hover color
--lc-reject-hoverReject button hover color
--lc-outlineBorder/outline color
--lc-radiusBorder radius
--lc-btn-radiusButton border radius
--lc-fontFont family
--lc-fsBase font size (other font sizes are derived from this)

Example: minimal banner

A basic GDPR banner with accept, reject, and customize buttons:

<div class="my-banner">
  <p class="title">{{opt_in_title}}</p>
  <p class="desc">{{{opt_in_description}}}</p>
  <div class="buttons">
    <button data-lc-action="accept_all">{{accept_text}}</button>
    <button data-lc-action="reject_all">{{reject_text}}</button>
    <button data-lc-action="preferences">{{customize_text}}</button>
  </div>
  {{{watermark_html}}}
</div>

Example: preferences panel

A preferences panel with category toggles and a save button:

<div class="my-prefs">
  <div class="header">
    <p>{{prefs_title}}</p>
    <button data-lc-action="close">&times;</button>
  </div>
  {{#categories}}
  <div class="category">
    <label>
      <span>{{name}}</span>
      {{^is_required}}
        <input type="checkbox" data-lc-toggle="{{slug}}">
      {{/is_required}}
      {{#is_required}}
        <input type="checkbox" checked disabled>
      {{/is_required}}
    </label>
    <p>{{description}}</p>
  </div>
  {{/categories}}
  <button data-lc-action="save">{{save_text}}</button>
</div>

Tips

  • Use CSS variables (var(--lc-accept), var(--lc-bg), etc.) so your template automatically picks up color changes from the dashboard.
  • Use {{#opt_in}} / {{#opt_out}} / {{#notice}} to show different content per jurisdiction. Do not remove these sections.
  • Use triple braces {{{...}}} for description fields and watermark_html because they may contain HTML.
  • Duplicate a system template to start with a working structure, then customize from there.
  • The data-lc-show-on-dirty / data-lc-hide-on-dirty attributes let you show a save button only after the visitor changes a toggle.