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

https://github.com/markmead/alpinejs-scroll-to

Easily add scroll to functionality with options, powered by Alpine JS 🐭
https://github.com/markmead/alpinejs-scroll-to

alpine-js alpinejs alpinejs-plugin javascript scroll-to scrollto

Last synced: 4 months ago
JSON representation

Easily add scroll to functionality with options, powered by Alpine JS 🐭

Awesome Lists containing this project

README

          

# Alpine JS Scroll To

Easily add scroll to functionality with options, powered by Alpine JS 🐭

## Install

### With a CDN

```html

```

### With a Package Manager

```shell
yarn add -D alpinejs-scroll-to

npm install -D alpinejs-scroll-to
```

```js
import Alpine from 'alpinejs'
import scrollTo from 'alpinejs-scroll-to'

Alpine.plugin(scrollTo)

Alpine.start()
```

## Example

```html



...





About


Team


About

Team




```

### Options

**`targetId`**

This expects the `id` of an element to scroll to without the `#`.

Useful for when you aren't triggering the scroll to from an anchor tag.

**`offsetHeader`**

By default this is `false`.

Setting this to `true` will offset the height of the header element when you
scroll. No more overlap!

You target the header element by applying `x-scroll-to-header` to it.

```html

...

```

**`useSmooth`**

By default this is `true`.

Setting this to `false` will remove the smooth scroll, instead it will be
instant.

## Stats

![](https://img.shields.io/bundlephobia/min/alpinejs-scroll-to)
![](https://img.shields.io/npm/v/alpinejs-scroll-to)
![](https://img.shields.io/npm/dt/alpinejs-scroll-to)
![](https://img.shields.io/github/license/markmead/alpinejs-scroll-to)