Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dolsem/perfectly-scrollable


https://github.com/dolsem/perfectly-scrollable

Last synced: 6 days ago
JSON representation

Awesome Lists containing this project

README

        

# Perfectly Scrollable

[![size](https://img.shields.io/bundlephobia/minzip/perfectly-scrollable?style=for-the-badge)](https://bundlephobia.com/package/perfectly-scrollable)
[![](https://img.shields.io/npm/v/perfectly-scrollable?style=for-the-badge)](https://www.npmjs.com/package/perfectly-scrollable)
[![](https://img.shields.io/npm/dw/perfectly-scrollable?style=for-the-badge)](https://www.npmjs.com/package/perfectly-scrollable)

SolidJS higher-order component for [Perfect Scrollbar](https://perfectscrollbar.com/).

## Installation

```bash
npm install perfectly-scrollable
```

## Example Usage

Define a scrollable component like this:
```tsx
// MyComponent.tsx
import { PerfectlyScrollable } from 'perfectly-scrollable';
import { Component } from 'solid-js';

export interface MyComponentProps {
ref?: JSX.IntrinsicAttributes['ref'];
title: string;
}
const MyComponent: Component => (props) => {
return (
// Make sure to pass the ref down to the element you want to make scrollable
// You should also make sure the CSS position property is set on the element


{props.title}



);
};

export default PerfectlyScrollable(MyComponent);
```

The resulting component props will include all `MyComponent` props and [all Perfect Scrollbar props](https://perfectscrollbar.com/#section-options):
```tsx
// App.tsx
import MyComponent from './MyComponent.tsx';
import { Component } from 'solid-js';

export default () => {
return (

);
};
```

You can add Perfect Scrollbar to native elements as well:
```tsx
// MyComponent.tsx
import { PerfectlyScrollable } from 'perfectly-scrollable';
import { Component } from 'solid-js';

const ScrollableDiv = PerfectlyScrollable('div');

export interface MyComponentProps {
ref?: JSX.IntrinsicAttributes['ref'];
title: string;
}
const MyComponent: Component => (props) => {
return (

{props.title}



);
};

export default MyComponent;
```

## Demo

View a functional demo on CodeSandbox: https://codesandbox.io/s/nxso2r.