1.0.12 • Published 11 months ago

@zendeskgarden/container-scrollregion v1.0.12

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
11 months ago

@zendeskgarden/container-scrollregion npm version

This package includes containers relating to scroll region in the Garden Design System.

Installation

npm install @zendeskgarden/container-scrollregion

Usage

Check out storybook for live examples.

As a hook

A scroll region is an area of the web page that contains scrollable content. The scroll region hook allows keyboard users to focus and scroll the region. A scroll region with a dynamic layout should use the dependency option. The hook re-calculates the tab-index when the dependency value changes. If there are multiple dependency values, a memoized object can be used as the dependency value.

import { useScrollRegion } from '@zendeskgarden/container-scrollregion';

const ScrollRegion = () => {
  const containerRef = useRef();
  const containerTabIndex = useScrollRegion({ containerRef });

  return (
    <div ref={containerRef} tabIndex={containerTabIndex}>
      <p>Turnip greens yarrow ricebean rutabaga endive cauliflower sea.</p>
    </div>
  );
};

As a Render Prop Component

import { ScrollRegionContainer } from '@zendeskgarden/container-scrollregion';

const ScrollRegion = () => {
  const containerRef = useRef();

  return (
    <ScrollRegionContainer containerRef={containerRef}>
      {containerTabIndex => (
        <div ref={containerRef} tabIndex={containerTabIndex}>
          <p>Turnip greens yarrow ricebean rutabaga endive cauliflower sea.</p>
        </div>
      )}
    </ScrollRegionContainer>;
  )
}
1.0.12

11 months ago

1.0.11

11 months ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.4

3 years ago

0.1.2

4 years ago

0.1.3

3 years ago

0.1.1

4 years ago

0.1.0

4 years ago