Magnetic
A magnetic effect that smoothly attracts elements to the mouse cursor based on configurable physics and proximity ranges.
Installation
npx raya-ui@latest add magneticFile Structure
your-project
components
ui
magnetic
Magnetic.vue
API Reference
Props
intensitynumber0.6Strength of the magnetic attraction. A value between 0 and 1 is recommended.
rangenumber100Pixel radius around the element where the magnetic effect becomes active.
actionAreaenum"self"Defines the hover trigger area boundary. Accepts 'self' (default), 'parent' (container), or 'global' (always active).
Vue component created & ported by the author of Raya UI.
Original concept by Motion Primitives
Settings
0.30
150
source-code.vue
<script setup lang="ts">
import { Magnetic } from '@/components/ui/magnetic'
import { Button } from '@/components/ui/button'
import { Plus } from 'lucide-vue-next'
</script>
<template>
<Magnetic
:intensity="0.3"
:range="150"
>
<Button variant="outline" class="rounded-full h-16 w-16 p-0 flex items-center justify-center border-2">
<Plus class="w-6 h-6" />
</Button>
</Magnetic>
</template>