Select to view content in your preferred language

Scrollbars for Accordion items - how?

172
2
Jump to solution
08-01-2024 10:38 AM
SteveCole
Frequent Contributor

The content inside my accordion items are too long so they get cut off. How do I add scrollbars? In general, the CSS controlling that would be "overflow-y" but I haven't been able to figure out the correct CSS item to target inside Calcite to get this to work.

 

Thanks!

Steve

0 Kudos
1 Solution

Accepted Solutions
KittyHurley
Esri Contributor

@SteveCole Within the Accordion Item you can add a parent element to house content and with CSS set a specified height and overflow-y value, similar to this example:

<style>
  .accordion-content {
    height: 15rem;
    overflow-y: scroll;
  }
</style>

<calcite-accordion>
  <calcite-accordion-item heading="My heading" description="My description">
    <div class="accordion-content">
       ...
    </div>
  </calcite-accordion-item>
</calcite-accordion>

 

View solution in original post

0 Kudos
2 Replies
KittyHurley
Esri Contributor

@SteveCole Within the Accordion Item you can add a parent element to house content and with CSS set a specified height and overflow-y value, similar to this example:

<style>
  .accordion-content {
    height: 15rem;
    overflow-y: scroll;
  }
</style>

<calcite-accordion>
  <calcite-accordion-item heading="My heading" description="My description">
    <div class="accordion-content">
       ...
    </div>
  </calcite-accordion-item>
</calcite-accordion>

 

0 Kudos
SteveCole
Frequent Contributor

Thank you, that did it. Sometimes it gets confusing when you're learning and throw together several different code snippits in order to piece together an app.

I'm a little leery about hard coding the height. When I didn't specify the height, it added the scrollbar but it would push other accordion items off the page because the accordion container had overflow hidden. Any thoughts on getting all this to play nice within the screen real estate? I have 6 accordion items and most of these will have content that needs scrolling.

Coming from the 3.x world and Dojo, I like how that accordion panel behaves and just pushes any unopened accordion items to the bottom and utilizes the available vertical screen space allotted for the overall accordion widget.

0 Kudos