I am attempting to create a toggle effect for an SVG icon, rotating it from the up position to the down position when clicked.
While a pure CSS solution would be ideal, I am struggling to implement it for an SVG icon. Unfortunately, I cannot use a font icon in this scenario; only an image or SVG can be utilized.
Is there a method I can use to achieve this effect?
.collapse-arrow .icon {
transition: .3s transform ease-in-out;
}
.collapse-arrow .collapsed .icon {
transform: rotate(-180deg);
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-12">
<div class="collapse-arrow">
<a data-toggle="collapse" class="collapsed" href="#collapseFilter">
<span class="icon">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="16px" height="16px" viewBox="0 0 451.847 451.847" style="enable-background:new 0 0 451.847 451.847;"
xml:space="preserve">
<g>
<path d="M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751
c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0
c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z"/>
</g>
</svg>
</span>
<strong>Link to toggle</strong>
</a>
<div class="collapse" id="collapseFilter">
<p>Some content I want collapsed or expanded</p>
</div>
</div>
</div>
</div>
</div>