You are here

color-field-formatter-swatch.html.twig in Color Field 8.2

Default theme implementation of a color swatch formatter.

Available variables:

  • color: The color background.
  • width: The width of the color swatch.
  • height: The height of the color swatch.
  • shape: The shape of the color swatch.

See also

template_preprocess()

template_preprocess_color_field_formatter_swatch()

File

templates/color-field-formatter-swatch.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation of a color swatch formatter.
  5. *
  6. * Available variables:
  7. * - color: The color background.
  8. * - width: The width of the color swatch.
  9. * - height: The height of the color swatch.
  10. * - shape: The shape of the color swatch.
  11. *
  12. * @see template_preprocess()
  13. * @see template_preprocess_color_field_formatter_swatch()
  14. *
  15. * @ingroup themeable
  16. */
  17. #}
  18. {% if shape == 'triangle' %}
  19. <div {{ attributes }} style="border-top: {{ width }} solid {{ color }}; border-right: {{ height }} solid transparent;"></div>
  20. {% else %}
  21. <div {{ attributes }} style="background-color: {{ color }}; width: {{ width }}; height: {{ height }};"></div>
  22. {% endif %}