MagicMarquee
MagicMarquee is a flexible, unstyled, CSS driven marquee component.
<template>
<magic-marquee
id="magic-marquee-demo"
class="bg-surface-base text-surface py-6"
>
<span>Magic as a Service™</span>
<span>Vue Equipment</span>
</magic-marquee>
</template>Overview
Anatomy
<template>
<magic-marquee>
<!-- your content -->
</magic-marquee>
</template>
<script setup>
const { play } = useMagicMarquee('your-marquee-id')
</script>Installation
CLI
Add @maas/vue-equipment to your dependencies.
pnpm install @maas/vue-equipmentnpm install @maas/vue-equipmentyarn add @maas/vue-equipmentbun install @maas/vue-equipmentVue
If you are using Vue, import and add MagicMarqueePlugin to your app.
import { createApp } from 'vue'
import { MagicMarqueePlugin } from '@maas/vue-equipment/plugins/MagicMarquee'
const app = createApp({})
app.use(MagicMarqueePlugin)Nuxt
The marquee is available as a Nuxt module. In your Nuxt config file add @maas/vue-equipment/nuxt to your modules and add MagicMarquee to the plugins in your configuration.
export default defineNuxtConfig({
modules: ['@maas/vue-equipment/nuxt'],
vueEquipment: {
plugins: ['MagicMarquee'],
},
})Composable
In order to interact with the marquee from anywhere within your app, we provide a useMagicMarquee composable. Import it directly when needed.
import { useMagicMarquee } from '@maas/vue-equipment/plugins/MagicMarquee'
const { play } = useMagicMarquee('your-marquee-id')
function handleClick() {
play()
}TIP
If you have installed the marquee as a Nuxt module, the composable will be auto-imported and is automatically available in your Nuxt app.
Peer Dependencies
If you haven’t installed the required peer dependencies automatically, you’ll need to install the following packages manually.
| Package |
|---|
@nuxt/kit |
@vueuse/core |
defu |
Installation
pnpm install @nuxt/kit @vueuse/core defunpm install @nuxt/kit @vueuse/core defuyarn add @nuxt/kit @vueuse/core defubun install @nuxt/kit @vueuse/core defuAPI Reference
Props
| Prop | Type | Required |
|---|---|---|
MaybeRef<string> | true | |
MagicMenuOptions | false |
Options
| Option | Type | Default |
|---|---|---|
normal | ||
number | 1 |
CSS Variables
| Variable | Default |
|---|---|
--magic-marquee-justify-content | flex-start |
--magic-marquee-align-items | baseline |
--magic-marquee-gap | 1rem |
--magic-marquee-content-width | unset |
Examples
Play Pause
<template>
<div class="flex flex-col items-center gap-8">
<magic-marquee
id="magic-marquee-play-pause-demo"
class="bg-surface-base text-surface rounded-surface-sm py-6"
>
<span>Magic as a Service™</span>
<span>Vue Equipment</span>
</magic-marquee>
<div class="flex w-full max-w-xs gap-2">
<m-button v-if="!isPlaying" block @click="play">Play</m-button>
<m-button v-else-if="isPlaying" block @click="pause">Pause</m-button>
</div>
</div>
</template>
<script lang="ts" setup>
import { MButton } from '@maas/mirror/vue'
import { useMagicMarquee } from '@maas/vue-equipment/plugins/MagicMarquee'
const { play, pause, isPlaying } = useMagicMarquee(
'magic-marquee-play-pause-demo'
)
</script>Playback Speed
<template>
<div class="flex flex-col items-center justify-center gap-8">
<magic-marquee
id="magic-marquee-playback-speed-demo"
class="bg-surface-base text-surface rounded-surface-sm py-6"
>
<span>Magic as a Service™</span>
<span>Vue Equipment</span>
</magic-marquee>
<div class="flex w-full max-w-xs gap-2">
<m-button block @click="decreaseSpeed(factor)">Slower</m-button>
<m-button block @click="increaseSpeed(factor)">Faster</m-button>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import { MButton } from '@maas/mirror/vue'
import { useMagicMarquee } from '@maas/vue-equipment/plugins/MagicMarquee'
const factor = ref(1)
const { increaseSpeed, decreaseSpeed } = useMagicMarquee(
'magic-marquee-playback-speed-demo'
)
</script>