Split hover letters
Latin text splits letter by letter and the glyph under your cursor leaps, spins or fills — three behaviours on one switch, with the neighbouring letters nudging along. Persian never splits by letter: it moves word by word so the joining never tears.
Real scenarios
The component as it is used in a product — not a specimen grid.
Glyphs that answer the cursor
The drop headline splits per letter for Latin; the glyph under your cursor acts while its two neighbours rise half a step, so a wave trails the pointer. Switch the behaviour — jump, spin, fill — and both lines obey.
Northwind Studio · flagship Rotterdam
نسخهٔ فارسی · واژهبهواژه
Persian is never split by letter — the joins would tear. The same three behaviours act on whole words instead.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| split | granularity | 'letter · latin' | Letter splitting only for Latin text; Persian breaks at word boundaries (preg_split on spaces) so the joins and stretches stay whole. |
| behaviour | attribute | 'jump' | Three behaviours via data-mode on the root: jump (a spring-eased hop), spin (a full 360° turn) and fill (a colour pill flooding the glyph). |
| neighbours | selector | '±1' | The letters flanking the hovered one rise half a step through :has and the adjacent-sibling combinator — a wave trails the cursor. |
| aria-label | a11y | 'whole line' | Every glyph is hidden from screen readers (aria-hidden) while the line’s label carries the full sentence. |
| reduced-motion | media | 'static' | Under prefers-reduced-motion transitions drop out; letters only take colour and stay still. |
Snippet
<div class="spl" x-data="{ mode: 'jump' }" x-bind:data-mode="mode">
<div class="spl-modes" role="group" aria-label="Letter behaviour">
<button type="button" x-bind:aria-pressed="mode === 'jump' ? 'true' : 'false'" x-on:click="mode = 'jump'">Jump</button>
<button type="button" x-bind:aria-pressed="mode === 'spin' ? 'true' : 'false'" x-on:click="mode = 'spin'">Spin</button>
<button type="button" x-bind:aria-pressed="mode === 'fill' ? 'true' : 'false'" x-on:click="mode = 'fill'">Fill</button>
</div>
<h2 class="spl-line" aria-label="SUMMER DROP">
@foreach (str_split('SUMMER DROP') as $i => $ch)
@if ($ch === ' ')
<span class="spl-gap" aria-hidden="true"></span>
@else
<span class="spl-l" style="--i: {{ $i }}" aria-hidden="true">{{ $ch }}</span>
@endif
@endforeach
</h2>
</div>
<style>
.spl { display: grid; gap: 1.25rem; justify-items: center; text-align: center; }
.spl-line { margin: 0; font-weight: 800; font-size: clamp(2rem, 8vw, 3.75rem); line-height: 1.25; }
.spl-l {
display: inline-block; transition: translate .28s cubic-bezier(.3, 1.6, .4, 1),
rotate .5s cubic-bezier(.3, .7, .2, 1), background-color .25s ease, color .25s ease;
}
.spl-gap { display: inline-block; inline-size: .38em; }
.spl[data-mode='jump'] .spl-l:hover { translate: 0 -.45em; color: #7c3aed; }
.spl[data-mode='spin'] .spl-l:hover { rotate: 360deg; color: #0891b2; }
.spl[data-mode='fill'] .spl-l:hover { background: #7c3aed; color: #fff; border-radius: .18em; padding-inline: .08em; }
.spl[data-mode='jump'] .spl-l:hover + .spl-l,
.spl[data-mode='jump'] .spl-l:has(+ .spl-l:hover) { translate: 0 -.16em; }
@media (prefers-reduced-motion: reduce) {
.spl-l { transition: color .25s ease, background-color .25s ease; }
}
</style>
// app/Pages/Drop.jsx — Inertia (React) page; renders the React snippet
// below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import SplitHover from '@/components/SplitHover';
export default function Drop() {
return (
<NabuXUIProvider locale="en" linkComponent={Link}>
<main className="nx-page">
<SplitHover />
</main>
</NabuXUIProvider>
);
}
// SplitHover.jsx — Latin letters leap under the cursor, words stay whole
import { useState } from 'react';
import '@nabuxai/ui-core/css';
const LINE = 'SUMMER DROP';
const MODES = ['jump', 'spin', 'fill'] as const;
export default function SplitHover() {
const [mode, setMode] = useState<'jump' | 'spin' | 'fill'>('jump');
return (
<>
<style>{`
.spl { display: grid; gap: 1.25rem; justify-items: center; text-align: center; }
.spl-line { margin: 0; font-weight: 800; font-size: clamp(2rem, 8vw, 3.75rem); line-height: 1.25; }
.spl-l { display: inline-block; transition: translate .28s cubic-bezier(.3, 1.6, .4, 1),
rotate .5s cubic-bezier(.3, .7, .2, 1), background-color .25s ease, color .25s ease; }
.spl-gap { display: inline-block; inline-size: .38em; }
.spl[data-mode='jump'] .spl-l:hover { translate: 0 -.45em; color: #7c3aed; }
.spl[data-mode='spin'] .spl-l:hover { rotate: 360deg; color: #0891b2; }
.spl[data-mode='fill'] .spl-l:hover { background: #7c3aed; color: #fff; border-radius: .18em; padding-inline: .08em; }
.spl[data-mode='jump'] .spl-l:hover + .spl-l,
.spl[data-mode='jump'] .spl-l:has(+ .spl-l:hover) { translate: 0 -.16em; }
@media (prefers-reduced-motion: reduce) { .spl-l { transition: color .25s ease, background-color .25s ease; } }
`}</style>
<div className="spl" data-mode={mode}>
<div className="spl-modes" role="group" aria-label="Letter behaviour">
{MODES.map((m) => (
<button type="button" key={m} aria-pressed={mode === m} onClick={() => setMode(m)}>{m}</button>
))}
</div>
<h2 className="spl-line" aria-label={LINE}>
{LINE.split('').map((ch, i) =>
ch === ' ' ? <span className="spl-gap" key={i} aria-hidden="true" />
: <span className="spl-l" key={i} aria-hidden="true">{ch}</span>,
)}
</h2>
</div>
</>
);
}
<!-- SplitHover.vue — Latin letters leap under the cursor, words stay whole -->
<script setup lang="ts">
import { ref } from 'vue';
import '@nabuxai/ui-core/css';
const LINE = 'SUMMER DROP';
const modes = ['jump', 'spin', 'fill'] as const;
const mode = ref<'jump' | 'spin' | 'fill'>('jump');
const letters = LINE.split('');
</script>
<template>
<div class="spl" :data-mode="mode">
<div class="spl-modes" role="group" aria-label="Letter behaviour">
<button v-for="m in modes" :key="m" type="button" :aria-pressed="mode === m" @click="mode = m">{{ m }}</button>
</div>
<h2 class="spl-line" :aria-label="LINE">
<template v-for="(ch, i) in letters" :key="i">
<span v-if="ch === ' '" class="spl-gap" aria-hidden="true" />
<span v-else class="spl-l" aria-hidden="true">{{ ch }}</span>
</template>
</h2>
</div>
</template>
<style scoped>
.spl { display: grid; gap: 1.25rem; justify-items: center; text-align: center; }
.spl-line { margin: 0; font-weight: 800; font-size: clamp(2rem, 8vw, 3.75rem); line-height: 1.25; }
.spl-l { display: inline-block; transition: translate .28s cubic-bezier(.3, 1.6, .4, 1),
rotate .5s cubic-bezier(.3, .7, .2, 1), background-color .25s ease, color .25s ease; }
.spl-gap { display: inline-block; inline-size: .38em; }
.spl[data-mode='jump'] .spl-l:hover { translate: 0 -.45em; color: #7c3aed; }
.spl[data-mode='spin'] .spl-l:hover { rotate: 360deg; color: #0891b2; }
.spl[data-mode='fill'] .spl-l:hover { background: #7c3aed; color: #fff; border-radius: .18em; padding-inline: .08em; }
.spl[data-mode='jump'] .spl-l:hover + .spl-l,
.spl[data-mode='jump'] .spl-l:has(+ .spl-l:hover) { translate: 0 -.16em; }
@media (prefers-reduced-motion: reduce) { .spl-l { transition: color .25s ease, background-color .25s ease; } }
</style>
<!-- SplitHover.svelte — Latin letters leap under the cursor, words stay whole -->
<script lang="ts">
import '@nabuxai/ui-core/css';
const LINE = 'SUMMER DROP';
const modes = ['jump', 'spin', 'fill'] as const;
let mode = $state<'jump' | 'spin' | 'fill'>('jump');
const letters = LINE.split('');
</script>
<div class="spl" data-mode={mode}>
<div class="spl-modes" role="group" aria-label="Letter behaviour">
{#each modes as m (m)}
<button type="button" aria-pressed={mode === m} onclick={() => (mode = m)}>{m}</button>
{/each}
</div>
<h2 class="spl-line" aria-label={LINE}>
{#each letters as ch, i (i)}
{#if ch === ' '}
<span class="spl-gap" aria-hidden="true"></span>
{:else}
<span class="spl-l" aria-hidden="true">{ch}</span>
{/if}
{/each}
</h2>
</div>
<style>
.spl { display: grid; gap: 1.25rem; justify-items: center; text-align: center; }
.spl-line { margin: 0; font-weight: 800; font-size: clamp(2rem, 8vw, 3.75rem); line-height: 1.25; }
.spl-l { display: inline-block; transition: translate .28s cubic-bezier(.3, 1.6, .4, 1),
rotate .5s cubic-bezier(.3, .7, .2, 1), background-color .25s ease, color .25s ease; }
.spl-gap { display: inline-block; inline-size: .38em; }
.spl[data-mode='jump'] .spl-l:hover { translate: 0 -.45em; color: #7c3aed; }
.spl[data-mode='spin'] .spl-l:hover { rotate: 360deg; color: #0891b2; }
.spl[data-mode='fill'] .spl-l:hover { background: #7c3aed; color: #fff; border-radius: .18em; padding-inline: .08em; }
.spl[data-mode='jump'] .spl-l:hover + .spl-l,
.spl[data-mode='jump'] .spl-l:has(+ .spl-l:hover) { translate: 0 -.16em; }
@media (prefers-reduced-motion: reduce) { .spl-l { transition: color .25s ease, background-color .25s ease; } }
</style>