Adhesive is a modern, performant, lightweight, dependency free library that provides advanced sticky positioning for web elements with cross-platform compatibility and framework-specific adapters.
This monorepo contains multiple packages for different use cases:
Package | Description | README | NPM | JSR |
---|---|---|---|---|
@adhesivejs/core |
Core library | 📖 README | ||
@adhesivejs/react |
React adapter | 📖 README | ||
@adhesivejs/svelte |
Svelte adapter | 📖 README | ||
@adhesivejs/vue |
Vue adapter | 📖 README |
# core
npx nypm install @adhesivejs/core
# react
npx nypm install @adhesivejs/react
# svelte
npx nypm install @adhesivejs/svelte
# vue
npx nypm install @adhesivejs/vue
import { Adhesive } from "@adhesivejs/core";
Adhesive.create({ targetEl: "#target-element" });
import { AdhesiveContainer } from "@adhesivejs/react";
export function Component() {
return (
<div>
<AdhesiveContainer position="top">
<header>This header will stick to the top</header>
</AdhesiveContainer>
<main>
<p>Your main content here...</p>
</main>
</div>
);
}
import { useAdhesive } from "@adhesivejs/react";
import { useRef } from "react";
export function Component() {
const targetRef = useRef<HTMLElement>(null);
useAdhesive(targetRef, { position: "top" });
return (
<div>
<header ref={targetRef}>This header will stick to the top</header>
<main>
<p>Your main content here...</p>
</main>
</div>
);
}
<script lang="ts">
import { adhesive } from "@adhesivejs/svelte";
</script>
<header {@attach adhesive({ position: "top" })}>
This header will stick to the top
</header>
<main>
<p>Your main content here...</p>
</main>
<script setup lang="ts">
import { AdhesiveContainer } from "@adhesivejs/vue";
</script>
<template>
<div>
<AdhesiveContainer position="top">
<header>This header will stick to the top</header>
</AdhesiveContainer>
<main>
<p>Your main content here...</p>
</main>
</div>
</template>
<script setup lang="ts">
import { useAdhesive } from "@adhesivejs/vue";
import { useTemplateRef } from "vue";
const targetRef = useTemplateRef("target");
useAdhesive(targetRef, () => ({ position: "top" }));
</script>
<template>
<div>
<header ref="target">This header will stick to the top</header>
<main>
<p>Your main content here...</p>
</main>
</div>
</template>
<script setup lang="ts">
import { vAdhesive } from "@adhesivejs/vue";
</script>
<template>
<div>
<header v-adhesive>This header will stick to the top</header>
<main>
<p>Your main content here...</p>
</main>
</div>
</template>
This project uses pnpm workspaces for monorepo management.
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Start development playgrounds
pnpm playground:core # Core playground
pnpm playground:react # React playground
pnpm playground:svelte # Svelte playground
pnpm playground:vue # Vue playground
# Lint all packages
pnpm lint
# Type check all packages
pnpm type-check
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.