Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 538 Bytes

File metadata and controls

27 lines (21 loc) · 538 Bytes

Craft Dynamic CSS Plugin

Collect dynamic CSS in Craft Twig templates and output them in the master template.

Add CSS in Nested Blocks

{% set style %}
  #{{ id }} {
    color: {{ block.textColor }};
    background-color: {{ block.backgroundColor }};
  }
{% endset %}
{{ craft.dynamiccss.set(style) }}

You can call set multiple times. All styles will be concatenated.

Output CSS in Master Template

{% if craft.dynamiccss.get() != '' %}
  <style>
    {{ craft.dynamiccss.get() }}
  </style>
{% endif %}