# Sliced Text

> A headline cut into bands like a sliced print: hover and the bands slide apart in alternate directions, revealing the word in a second colour through the cut.

Category: Text · Free · Updated 2026-11-10 · Live demo: https://www.motionkitui.com/components/sliced-text

## When to use it

Editorial and portfolio headings, fashion and agency sites, navigation labels and big type that should reward a hover.

## How it works

The word is stacked several times in the same grid cell. Each copy is clipped with clip-path to one horizontal band, so together they look like a single word. On hover each band springs sideways, alternating left and right with a small stagger, and a copy in the accent colour fades in behind them, showing through where the bands have parted. The element is labelled with the text and every copy is hidden from screen readers, so it's read once.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/sliced-text.json
```

Or copy `components/motionkit/sliced-text.tsx` below. Requires react, motion and Tailwind CSS v4. Free for personal projects; commercial use needs MotionKit Plus (https://www.motionkitui.com/pricing).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `text` | `string` |  | The word or line. |
| `slices` | `number` | `3` | Number of horizontal bands. |
| `offset` | `number` | `0.06` | How far the bands slide, as a share of the width. |
| `color` | `string` | `"#F6F1E8"` | Colour at rest. |
| `accent` | `string` | `"#5FAEB4"` | Colour revealed through the cut. |
| `as` | `ElementType` | `"span"` | Element to render, e.g. h1. |

## Accessibility

- **Keyboard: Not applicable.** Text, not a control; the slide is decoration on hover.
- **Screen readers: Pass.** Read once from its label; the slices and the accent copy are hidden.
- **Reduced motion: Pass.** With reduced motion on, the bands stay together and only the colour changes.
- **Colour contrast: Pass.** Ivory measures 17:1 on the site's dark and the default accent 7.5:1.

## Source

```tsx
"use client";

import { useState, type ElementType } from "react";
import { motion, useReducedMotion } from "motion/react";

type SlicedTextProps = {
  text: string;
  /** Number of horizontal bands the letters are cut into. */
  slices?: number;
  /** How far the bands slide apart, as a share of the text's width. */
  offset?: number;
  /** Colour of the letters at rest. */
  color?: string;
  /** Colour revealed inside the cut when the bands slide. */
  accent?: string;
  /** The element to render, e.g. "h1". */
  as?: ElementType;
  className?: string;
};

/**
 * A headline cut into bands like a print sliced with a scalpel. Hover and the bands slide apart in
 * alternate directions, revealing the same word in a second colour through the cut, then snap back together.
 */
export function SlicedText({ text, slices = 3, offset = 0.06, color = "#F6F1E8", accent = "#5FAEB4", as: Tag = "span", className = "" }: SlicedTextProps) {
  const reduceMotion = useReducedMotion();
  const [open, setOpen] = useState(false);
  const count = Math.max(2, Math.round(slices));
  const shift = reduceMotion ? 0 : offset * 100;

  return (
    <Tag
      aria-label={text}
      onPointerEnter={() => setOpen(true)}
      onPointerLeave={() => setOpen(false)}
      className={`relative inline-grid cursor-default select-none whitespace-nowrap ${className}`}
    >
      {/* the accent copy behind, seen through the gaps as the bands slide */}
      <motion.span
        aria-hidden
        className="col-start-1 row-start-1"
        style={{ color: accent }}
        initial={false}
        animate={{ opacity: open ? 1 : 0, scaleX: open ? 1 : 0.92 }}
        transition={{ duration: reduceMotion ? 0 : 0.35 }}
      >
        {text}
      </motion.span>
      {Array.from({ length: count }, (_, index) => {
        const top = (index / count) * 100;
        const bottom = 100 - ((index + 1) / count) * 100;
        const direction = index % 2 === 0 ? -1 : 1;
        return (
          <motion.span
            key={index}
            aria-hidden
            className="col-start-1 row-start-1"
            // neighbouring bands overlap by a pixel, so no hairline shows between them at rest
            style={{ color, clipPath: `inset(calc(${top}% - 1px) -20% calc(${bottom}% - 1px) -20%)` }}
            initial={false}
            animate={{ x: open ? `${direction * shift}%` : "0%", opacity: open ? 0.92 : 1 }}
            transition={reduceMotion ? { duration: 0 } : { type: "spring", stiffness: 320, damping: 24, delay: open ? index * 0.03 : (count - index) * 0.02 }}
          >
            {text}
          </motion.span>
        );
      })}
    </Tag>
  );
}
```
