title: How add drop-down arrow states in Bootstrap 4 accordion using Angular or CSS
body: <p>How can I implement a simple arrow (>) to indicate the <code>aria-expanded="true" or aria-expanded="false"</code> states in the Bootstrap 4 accordion using either Angular2 or plain CSS?</p>
  
  <p>I have watched a bunch of tutorials and tried even more, but I think I am missing something. </p>
  
  <p>I have tried using CSS only, but the arrow does not display (this might be the way to go):</p>
  
  <pre><code>.card .card-header:after{
      float: right;
      border: 2px solid #f07f09;
      border-width: 0 3px 3px 0;
      padding: 6px;
      margin-right: 10px;
  }
  </code></pre>
  
  <p>And I have tried using <code>ngClass</code>, but my issue is that it applies the arrow state to all elements with the below code (is there a way to use index to make this work?): </p>
  
  <pre><code>&lt;i [ngClass]="{'right':!expanded, 'down':expanded}"&gt;&lt;/i&gt;
  </code></pre>
  
  <p>and the method setting the state:</p>
  
  <pre><code>(click)="changeDropdownArrowState()"
  </code></pre>
  
  <p>Method in my component:</p>
  
  <pre><code>  changeDropdownArrowState () {
      this.expanded = !this.expanded;
    }
  </code></pre>
  
  <p>My HTML:</p>
  
  <pre><code>&lt;div class="card"&gt;
      &lt;div class="card-header" id="headingOne"&gt;
          &lt;h2 class="mb-0"&gt;
              &lt;button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse"
                  data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne" (click)="changeDropdownArrowState()"&gt;
                  &lt;h1&gt;Personal Details
                      &lt;i [ngClass]="{'right':!expanded, 'down':expanded}"&gt;&lt;/i&gt;
                  &lt;/h1&gt;
              &lt;/button&gt;
          &lt;/h2&gt;
  
      &lt;/div&gt;
  
      &lt;div id="collapseOne" class="collapse" aria-labelledby="headingOne" data-parent="#retailCliamAccordian"&gt;
          &lt;div class="card-body"&gt;
              some text
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="card"&gt;
      &lt;div class="card-header" id="headingTwo"&gt;
          &lt;h2 class="mb-0"&gt;
              &lt;button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse"
                  data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo" (click)="changeDropdownArrowState()"&gt;
                  &lt;h1&gt;Product Details
                      &lt;i [ngClass]="{'right':!expanded, 'down':expanded}"&gt;&lt;/i&gt;
                  &lt;/h1&gt;
              &lt;/button&gt;
          &lt;/h2&gt;
      &lt;/div&gt;
      &lt;div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#retailCliamAccordian"&gt;
          &lt;div class="card-body"&gt;
              other text
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My CSS:</p>
  
  <pre><code>i {
      float: right;
      border: 2px solid #f07f09;
      border-width: 0 3px 3px 0;
      padding: 6px;
      margin-right: 10px;
  }
  
  .right {
      transform: rotate(-45deg);
  }
  
  .down {
      transform: rotate(45deg);
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/CrDF8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CrDF8.png" alt="enter image description here"></a></p>
  
  <p>I think using the attribute <code>aria-expanded="true/false"</code> might be another way to go.</p>