Scroll Area
Область прокрутки: свои полосы, мягкие края, прилипание к низу для чатов. Бесплатно, MIT · Навигация и каркас › Каркас
Установка
npx valyro-cli@latest add scroll-area
npx shadcn@latest add https://valyro.xyz/r/scroll-area.json
npm install valyro-ui
import 'valyro-ui/styles.css';
import { ScrollArea } from 'valyro-ui';
Пропсы
| Prop | Type | Default | |
|---|---|---|---|
children | ReactNode | Content, or the compound parts ScrollArea.Viewport (with ScrollArea.Content), .Scrollbar, .Corner and .ScrollButton. | |
orientation | 'vertical' | 'horizontal' | 'both' | 'vertical' | Axes that scroll. Default vertical. |
scrollbars | 'overlay' | 'native' | 'hidden' | 'overlay' | overlay: the kit's thin bars over the content; native: the browser's bars in theme colours; hidden: none (wheel, touch and keys still scroll). Default overlay. |
visibility | 'hover' | 'scroll' | 'auto' | 'always' | 'hover' | When overlay bars show: while the pointer is over the area, while scrolling, whenever it overflows, or always. Default hover. |
hideDelay | number | 600 | Ms before overlay bars hide after the pointer leaves or scrolling stops. Default 600. |
edges | 'fade' | 'shadow' | 'none' | 'fade' | Hint at content hidden past an edge: a soft mask, an inset shadow, or nothing. Default fade. |
edgeSize | number | Depth of the fade or shadow, px. Default --ui-scroll-area-edge-size (24px). | |
follow | boolean | Keep the end in view while content grows (chats, logs): any scroll back releases it, reaching the end picks it up again. Controlled: pair with onFollowChange. Passing this or defaultFollow turns follow mode on. | |
defaultFollow | boolean | Initial follow when uncontrolled. | |
onFollowChange | (follow: boolean) => void | Called with the new follow when it changes. | |
threshold | number | 32 | Distance from the end, px, that counts as being at it. Default 32. |
initialScroll | 'start' | 'end' | Where it opens; end is applied before the first paint (no flash of the top). Default start, or end while following. | |
onEdgeReached | (edge: ScrollAreaEdge) => void | Called once each time an edge is reached (load more, older messages). start / end are the inline sides and mirror in RTL. | |
scrollButton | boolean | Floating "scroll to end" button while the end is out of view. Default: on in follow mode. | |
label | string | Accessible name of the scroll region, applied (with role="region") only while it overflows. | |
viewportRef | Ref<HTMLDivElement> | Ref of the scrolling element (the root gets ref, className, style, data-* and aria-*). | |
viewportProps | ComponentPropsWithRef<'div'> | Props of the scrolling element. | |
labels | Partial<ScrollAreaLabels> | Overrides for the built-in English text; keys left out keep their defaults. |
Составные части
ScrollArea.Viewport (ScrollAreaViewport), ScrollArea.Content (ScrollAreaContent), ScrollArea.Scrollbar (ScrollAreaScrollbar), ScrollArea.Thumb (ScrollAreaThumb), ScrollArea.Corner (ScrollAreaCorner), ScrollArea.ScrollButton (ScrollAreaScrollButton)
Похожие компоненты
- App Shell — Каркас приложения
- Navbar — Верхняя навигация
- Sidebar — Боковая панель
- Resizable Panels — Панели с изменяемым размером
- Breadcrumbs — Хлебные крошки
- Tabs — Вкладки
- Segmented Control — Переключатель режимов
- Toggle Group — Кнопки-переключатели: форматирование, выравнивание, фильтры
- Pagination — Постраничная навигация
- Stepper — Пошаговые процессы
- Dropdown Menu — Выпадающее меню
- Context Menu — Контекстное меню
Назад: Resizable Panels · Далее: Breadcrumbs · Весь раздел «Навигация и каркас»