Scrollable 是一个实验性的 WordPress 布局组件,用于在可滚动容器中显示内容。它允许开发者通过设置最大高度和滚动方向来控制内容的滚动行为。
import { __experimentalScrollable as Scrollable } from '@wordpress/components';
function Example() {
return (
<Scrollable style={ { maxHeight: 200 } }>
<div style={ { height: 500 } }>...</div>
</Scrollable>
);
}由于 Scrollable 是实验性功能,建议在非生产环境中测试,并关注 WordPress 更新以避免兼容性问题。
Scrollable is a layout component that content in a scrollable container.
import { __experimentalScrollable as Scrollable } from '@wordpress/components';
function Example() {
return (
<Scrollable style={ { maxHeight: 200 } }>
<div style={ { height: 500 } }>...</div>
</Scrollable>
);
}
children: ReactNodeThe children elements.
scrollDirection: stringRenders a scrollbar for a specific axis when content overflows.
yx, y, autosmoothScroll: booleanEnables (CSS) smooth scrolling.
false