Vitral 0.2.18
Painel

ScrollPanel

Um contêiner de rolagem com as barras finas do próprio tema, sobre a rolagem nativa — as mesmas barras de todo componente que rola por dentro, e que o v-scrollbar coloca numa caixa sua.

Importação

main.ts
import { ScrollPanel } from '@vitral/vue';

Vertical e horizontal

Paragraph 1. Vitral draws the scrollbars of this panel with the theme's tokens, while the browser keeps doing the scrolling, so the wheel, touch, and the arrow and page keys all work as they do anywhere else.

Paragraph 2. Vitral draws the scrollbars of this panel with the theme's tokens, while the browser keeps doing the scrolling, so the wheel, touch, and the arrow and page keys all work as they do anywhere else.

Paragraph 3. Vitral draws the scrollbars of this panel with the theme's tokens, while the browser keeps doing the scrolling, so the wheel, touch, and the arrow and page keys all work as they do anywhere else.

Paragraph 4. Vitral draws the scrollbars of this panel with the theme's tokens, while the browser keeps doing the scrolling, so the wheel, touch, and the arrow and page keys all work as they do anywhere else.

Paragraph 5. Vitral draws the scrollbars of this panel with the theme's tokens, while the browser keeps doing the scrolling, so the wheel, touch, and the arrow and page keys all work as they do anywhere else.

Paragraph 6. Vitral draws the scrollbars of this panel with the theme's tokens, while the browser keeps doing the scrolling, so the wheel, touch, and the arrow and page keys all work as they do anywhere else.

Paragraph 7. Vitral draws the scrollbars of this panel with the theme's tokens, while the browser keeps doing the scrolling, so the wheel, touch, and the arrow and page keys all work as they do anywhere else.

Paragraph 8. Vitral draws the scrollbars of this panel with the theme's tokens, while the browser keeps doing the scrolling, so the wheel, touch, and the arrow and page keys all work as they do anywhere else.

<script setup lang="ts">import { ScrollPanel } from '@vitral/vue'; const paragraphs = Array.from({ length: 8 }, (_, i) => `Paragraph ${i + 1}. Vitral draws the scrollbars of this panel with the theme's tokens, while the browser keeps doing the scrolling, so the wheel, touch, and the arrow and page keys all work as they do anywhere else.`);</script> <template>    <ScrollPanel aria-label="Notes" style="width: 100%; max-width: 28rem; height: 14rem; border: 1px solid var(--vt-content-border-color); border-radius: 8px">        <div style="padding: 1rem; width: 40rem">            <p v-for="p in paragraphs" :key="p" style="margin: 0 0 0.75rem">{{ p }}</p>        </div>    </ScrollPanel></template>

Quando as barras aparecem

`scrollbar` é `'hover'` por padrão: as barras aparecem enquanto o ponteiro está sobre o painel, o foco está dentro dele ou ele rola. `'always'` as mantém na tela, e `'native'` devolve as do navegador. `arrows` coloca setas nas pontas delas, como numa barra nativa. A mesma prop está em todo componente que rola por dentro (Sidebar, Select, Dialog, Drawer, DataGrid e os demais), e a opção `scrollbar` da aplicação define todas de uma vez. Só o polegar recebe o ponteiro: um clique na faixa chega ao conteúdo embaixo dela.

  • Item 1
  • Item 2
  • Item 3
  • Item 4
  • Item 5
  • Item 6
  • Item 7
  • Item 8
  • Item 9
  • Item 10
  • Item 11
  • Item 12
  • Item 13
  • Item 14
  • Item 15
  • Item 16
  • Item 17
  • Item 18
  • Item 19
  • Item 20
  • Item 21
  • Item 22
  • Item 23
  • Item 24
<script setup lang="ts">import { ScrollPanel, SelectButton, ToggleSwitch } from '@vitral/vue';import { ref } from 'vue'; const mode = ref<'hover' | 'always' | 'native'>('always');const arrows = ref(false);const modes = ['hover', 'always', 'native'];const items = Array.from({ length: 24 }, (_, i) => `Item ${i + 1}`);</script> <template>    <div style="display: flex; flex-direction: column; gap: 1rem; align-items: flex-start">        <div style="display: flex; flex-wrap: wrap; align-items: center; gap: 1rem">            <SelectButton v-model="mode" :options="modes" :allow-empty="false" aria-label="Scrollbar" />            <label style="display: inline-flex; align-items: center; gap: 0.5rem"><ToggleSwitch v-model="arrows" /> Arrows</label>        </div>        <ScrollPanel :scrollbar="mode" :arrows="arrows" aria-label="Items" style="width: 16rem; max-height: 12rem; border: 1px solid var(--vt-content-border-color); border-radius: 8px">            <ul style="margin: 0; padding: 0.5rem 1rem; list-style: none">                <li v-for="item in items" :key="item" style="padding: 0.25rem 0">{{ item }}</li>            </ul>        </ScrollPanel>    </div></template>

Conteúdo que cresce

As barras acompanham o conteúdo, além do painel: uma seção que abre com animação, uma imagem que carrega.

The bar is measured again when what is inside grows, not only when the panel does: open the section and its thumb shrinks while the section is still opening.

Section line 1. An image that finishes loading, or text that arrives, is followed in the same way.

Section line 2. An image that finishes loading, or text that arrives, is followed in the same way.

Section line 3. An image that finishes loading, or text that arrives, is followed in the same way.

Section line 4. An image that finishes loading, or text that arrives, is followed in the same way.

Section line 5. An image that finishes loading, or text that arrives, is followed in the same way.

Section line 6. An image that finishes loading, or text that arrives, is followed in the same way.

<script setup lang="ts">import { Button, ScrollPanel } from '@vitral/vue';import { ref } from 'vue'; const open = ref(false);</script> <template>    <div style="display: flex; flex-direction: column; gap: 1rem; align-items: flex-start">        <Button :label="open ? 'Close the section' : 'Open the section'" severity="secondary" @click="open = !open" />        <ScrollPanel scrollbar="always" aria-label="Report" style="width: 100%; max-width: 28rem; height: 12rem; border: 1px solid var(--vt-content-border-color); border-radius: 8px">            <div style="padding: 1rem">                <p style="margin: 0 0 0.75rem">The bar is measured again when what is inside grows, not only when the panel does: open the section and its thumb shrinks while the section is still opening.</p>                <div :style="{ display: 'grid', gridTemplateRows: open ? '1fr' : '0fr', transition: 'grid-template-rows 400ms ease' }">                    <div style="overflow: hidden">                        <p v-for="n in 6" :key="n" style="margin: 0 0 0.75rem">Section line {{ n }}. An image that finishes loading, or text that arrives, is followed in the same way.</p>                    </div>                </div>            </div>        </ScrollPanel>    </div></template>

Caixas suas

`v-scrollbar` coloca as mesmas barras numa caixa sua que já rola, sem embrulhá-la: ela mantém o lugar no layout e a rolagem nativa. `v-scrollbar.always`, `.hover` e `.native`, ou um valor, dizem quando elas aparecem; sem nenhum, decide a opção `scrollbar` da aplicação. `.arrows` coloca setas nas pontas, como numa barra nativa — um clique rola um passo, segurar continua rolando —, e a opção `scrollbarArrows` da aplicação faz o mesmo em todas as barras.

Student 1

Student 2

Student 3

Student 4

Student 5

Student 6

Student 7

Student 8

Student 9

Student 10

Student 11

Student 12

Student 13

Student 14

Student 15

Student 16

Student 17

Student 18

Student 19

Student 20

Student 16.0
Student 26.7
Student 37.4
Student 48.1
Student 58.8
Student 69.5
Student 76.2
Student 86.9
Student 97.6
Student 108.3
Student 119.0
Student 129.7
Student 136.4
Student 147.1
Student 157.8
Student 168.5
Student 179.2
Student 189.9
Student 196.6
Student 207.3

Student 1: grade 6.0, entered on the term's sheet

Student 2: grade 6.7, entered on the term's sheet

Student 3: grade 7.4, entered on the term's sheet

Student 4: grade 8.1, entered on the term's sheet

Student 5: grade 8.8, entered on the term's sheet

Student 6: grade 9.5, entered on the term's sheet

Student 7: grade 6.2, entered on the term's sheet

Student 8: grade 6.9, entered on the term's sheet

Student 9: grade 7.6, entered on the term's sheet

Student 10: grade 8.3, entered on the term's sheet

Student 11: grade 9.0, entered on the term's sheet

Student 12: grade 9.7, entered on the term's sheet

Student 13: grade 6.4, entered on the term's sheet

Student 14: grade 7.1, entered on the term's sheet

Student 15: grade 7.8, entered on the term's sheet

Student 16: grade 8.5, entered on the term's sheet

Student 17: grade 9.2, entered on the term's sheet

Student 18: grade 9.9, entered on the term's sheet

Student 19: grade 6.6, entered on the term's sheet

Student 20: grade 7.3, entered on the term's sheet

<script setup lang="ts">import { Scrollbar as vScrollbar } from '@vitral/vue'; const rows = Array.from({ length: 20 }, (_, i) => ({ id: i + 1, name: `Student ${i + 1}`, grade: (6 + ((i * 7) % 40) / 10).toFixed(1) }));</script> <template>    <div style="display: flex; flex-wrap: wrap; gap: 1rem">        <div v-scrollbar aria-label="Students" role="region" tabindex="0" style="width: 16rem; height: 12rem; overflow: auto; border: 1px solid var(--vt-content-border-color); border-radius: 8px">            <p v-for="row in rows" :key="row.id" style="margin: 0; padding: 0.375rem 1rem">{{ row.name }}</p>        </div>        <div v-scrollbar.always aria-label="Grades" role="region" tabindex="0" style="width: 16rem; height: 12rem; overflow: auto; border: 1px solid var(--vt-content-border-color); border-radius: 8px">            <table style="width: 100%; border-collapse: collapse">                <tbody>                    <tr v-for="row in rows" :key="row.id">                        <td style="padding: 0.375rem 1rem">{{ row.name }}</td>                        <td style="padding: 0.375rem 1rem; text-align: right">{{ row.grade }}</td>                    </tr>                </tbody>            </table>        </div>        <div v-scrollbar.always.arrows aria-label="Term notes" role="region" tabindex="0" style="width: 16rem; height: 12rem; overflow: auto; border: 1px solid var(--vt-content-border-color); border-radius: 8px">            <div style="width: 26rem; padding: 0.5rem 1rem">                <p v-for="row in rows" :key="row.id" style="margin: 0; padding: 0.25rem 0">{{ row.name }}: grade {{ row.grade }}, entered on the term's sheet</p>            </div>        </div>    </div></template>

API

Lido de packages/vue/src/components/ScrollPanel/types.ts, então diz o que o componente aceita de fato.

Props

NomeTipoDescrição
arrows Novo na 0.2.16booleanSetas nas pontas das barras, como numa barra nativa: um clique rola um passo e segurar continua rolando. Por padrão é a opção `scrollbarArrows` da aplicação, que vem desligada.
scrollbar ScrollbarModeAs barras das caixas que este componente rola por dentro: `'hover'`, `'always'` ou `'native'`. Por padrão é a opção `scrollbar` da aplicação, que é `'hover'`.

Mais pt, dt e unstyled de BaseProps; veja pass-through e modo sem estilo.

Slots

NomeProps do slotDescrição
default ——