Scroll Area
A bounded, keyboard-reachable scroll region with styled scrollbars.
Installation
Included in poetry-ui — available as
poetry_scroll_area
the moment you've installed Poetry,
with no per-component step. To own the source and edit it, copy it into your app:
bin/rails g poetry:add scroll-area
Default
Open Default standalone
<%= poetry_scroll_area(label: "Tags", class: "h-72 w-48 rounded-md border") do %>
<div class="p-4">
<h4 class="mb-4 text-sm leading-none font-medium">Tags</h4>
<% (1..30).each do |n| %>
<div class="border-b py-2 text-sm last:border-0">v1.2.0-beta.<%= n %></div>
<% end %>
</div>
<% end %>
Horizontal
Open Horizontal standalone
<%= poetry_scroll_area(label: "Artwork strip", class: "w-96 rounded-md border") do %>
<div class="flex w-max gap-4 p-4">
<% (1..8).each do |n| %>
<div class="flex h-32 w-40 shrink-0 items-center justify-center rounded-md bg-muted text-sm">
Artwork <%= n %>
</div>
<% end %>
</div>
<% end %>
API
Poetry::Ui::ScrollArea::Component — options are
constructor keywords (the poetry_* helper forwards them);
slots are composed inside the block. Generated from the gem's source documentation.
| Option | Type | Details | Description |
|---|---|---|---|
| label: | String | required | The region's accessible name (role=region + aria-label) - required, because a focusable region must be named. |
Styling
Every part carries a stable data-slot attribute — target
[data-slot=…] from your own CSS to restyle it. State rides
data attributes on the parts below. This contract is verified against rendered DOM in CI.
| Part | Description |
|---|---|
| [data-slot=scroll-area] | The bounding wrapper - size it with classes; content decides the overflow |
| [data-slot=scroll-area-viewport] | The focusable native scroll region (role=region + tabindex=0) with themed platform scrollbars - zero JS |