Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

Twig Font Awesome

Security covered

Part of the Twig ecosystem · 26 projects

View on drupal.org

Introduction

The Twig Font Awesome module provides a simple Twig function for inserting Font Awesome icons as inline SVGs.

Inline SVGs have many advantages over icon fonts (see https://css-tricks.com/icon-fonts-vs-svg). However, actually using them can be a bit of a hassle as SVG elements are bulky and difficult to identify in source code.

This module makes it possible to use inline SVGs from Font Awesome without having to deal with the actual SVG code.

Installation

  1. Install the module as usual.
  2. Upload the svgs folder from Font Awesome to /libraries/fontawesome/svgs. Both free and pro versions can be used.

Usage Example

Adding this to a Twig template:

{{ fa('solid', 'house') }}

Will output an inline SVG:

<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--! Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M575.8 255.5c0 18-15 32.1-32 32.1h-32l.7 160.2c0 2.7-.2 5.4-.5 8.1V472c0 22.1-17.9 40-40 40H456c-1.1 0-2.2 0-3.3-.1c-1.4 .1-2.8 .1-4.2 .1H416 392c-22.1 0-40-17.9-40-40V448 384c0-17.7-14.3-32-32-32H256c-17.7 0-32 14.3-32 32v64 24c0 22.1-17.9 40-40 40H160 128.1c-1.5 0-3-.1-4.5-.2c-1.2 .1-2.4 .2-3.6 .2H104c-22.1 0-40-17.9-40-40V360c0-.9 0-1.9 .1-2.8V287.6H32c-18 0-32-14-32-32.1c0-9 3-17 10-24L266.4 8c7-7 15-8 22-8s15 2 21 7L564.8 231.5c8 7 12 15 11 24z"/></svg>

API Reference

{{ fa(style, name, attributes) }}

style: Required. The icon style. Examples: 'regular', 'sharp-solid'

name: Required. The icon name without the 'fa-' prefix. Example: 'acorn'

attributes: Optional. An array of additional attributes to add to the SVG. Example: {class: 'hidden'}

Similar modules

  • Font Awesome SVG: Provides icons through Icon API instead of a Twig function.
  • Twig SVG: Works with SVG sprites instead of inline SVGs.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Aug 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
1.0.0-beta3 Pre-release Jan 10, 2024
1.0.0-beta2 Pre-release Oct 31, 2023
1.0.0-beta1 Pre-release Aug 17, 2023
1.x-dev Dev Aug 17, 2023