> For the complete documentation index, see [llms.txt](https://atomico.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atomico.gitbook.io/doc/packages/atomico-components/keen-slider.md).

# @atomico/keen-slider

The Keen-slider api but with WebComponents

**Webcomponent** built with [Atomico JS](https://atomicojs.dev/) to use [keen-slider](https://keen-slider.io/) as webcomponent. Includes additional support for React and Preact.

{% embed url="<https://codepen.io/uppercod/pen/MWVENee>" %}

{% embed url="<https://github.com/atomicojs/components/tree/master/src/components/keen-slider>" %}

### Modules

{% tabs %}
{% tab title="Default" %}

```javascript
import { KeenSlider } from "@atomico/keen-slider";
```

{% endtab %}

{% tab title="Elements" %}

```javascript
// Import that does not associate the tagName by default
import { KeenSlider } from "@atomico/keen-slider/elements";
```

{% endtab %}

{% tab title="React" %}

```javascript
import { KeenSlider } from "@atomico/keen-slider/react";
```

{% endtab %}

{% tab title="Preact" %}

```javascript
import { KeenSlider } from "@atomico/keen-slider/preact";
```

{% endtab %}

{% tab title="Html CDN" %}

```html
<script 
    type="module" 
    src="http://esm.sh/@atomico/keen-slider"></script>
    
<atomico-keen-slider><atomico-keen-slider>
```

{% endtab %}
{% endtabs %}

### Properties / attributes

most of the properties are homologous to [keen-slider documentation](https://keen-slider.io/docs)

| Prop/Attr                           | Type / default                  | Description                                                                                                                                                      |
| ----------------------------------- | ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **loop**                            | boolean                         | Enables or disables carousel/loop functionality of the slider.                                                                                                   |
| **drag**                            | boolean                         | Enables or disables mouse and touch control. Default is **tru**                                                                                                  |
| **disabled**                        | boolean                         |                                                                                                                                                                  |
| **vertical**                        | boolean                         | Changes the direction of the slider from horizontal to vertical. (Note: The height of the `container` must be defined if vertical is true) Default is **false**. |
| **rtl**                             | boolean                         | Changes the direction in which the slides are positioned, from left-to-right to right-to-left. Default is **false**.                                             |
| **rubberband**                      | boolean                         | Enables or disables the rubberband behavior for dragging and animation after a drag. Default is **tr**                                                           |
| **autoplay**                        | boolean                         |                                                                                                                                                                  |
| **autoplayLoop / autoplay-loop**    | number / 2000                   |                                                                                                                                                                  |
| **initial**                         | number                          |                                                                                                                                                                  |
| **mode**                            | "snap" \| "free" \| "free-snap" |                                                                                                                                                                  |
| **slidesPerView / slides-per-view** | string                          |                                                                                                                                                                  |
| **slidesSpacing / slides-spacing**  | string                          |                                                                                                                                                                  |
| **slidesOrigin / slides-origin**    | string                          |                                                                                                                                                                  |
| **slider**                          | KeenSliderInstance              |                                                                                                                                                                  |

The slidesPerView, slidesSpacing and slidesOrigin props accept responsive expressions, example:

```html
<atomico-keen-slider 
    slider-per-view="1, 2 520px, 3 720px"
></atomico-keen-slider>
```

### Events

**CreateSlider**

dispatched when defining the slider prop, useful for accessing the keen-slider instance

### Methods

`KeenSlider.next()`

next slide

`KeenSlider.prev()`

prev slide

### Examples

#### React

{% embed url="<https://stackblitz.com/edit/atomico-keen-slider-react?file=src/App.tsx>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://atomico.gitbook.io/doc/packages/atomico-components/keen-slider.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
