# M text generate effect 2

> AI chat response — assistant card regenerates text on demand via trigger

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/m-text-generate-effect-2).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/m-text-generate-effect-2
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/cnippet/m-text-generate-effect-2-light-6a4d48334dab60af.png
- Registry item: https://ui.cnippet.dev/r/m-text-generate-effect-2.json
- Categories: text generate effect
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ui.cnippet.dev/r/m-text-generate-effect-2.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@cnippet/text-generate-effect`

## Files

### `registry/default/motion-variants/m-text-generate-effect-2.tsx`

```tsx
//biome-ignore-all lint/style/noNonNullAssertion:<>

"use client";

import { useState } from "react";
import { TextGenerateEffect } from "@/registry/default/motion/text-generate-effect";

const responses = [
  "Here are 164 animated components built on Motion and Tailwind CSS, ready to copy and paste into your project.",
  "Each component ships with a source file, three real-world examples, and a CLI install command.",
];

export default function TextGenerateEffectAI() {
  const [index, setIndex] = useState(0);
  const [trigger, setTrigger] = useState(true);

  const regenerate = () => {
    setTrigger(false);
    setTimeout(() => {
      setIndex((i) => (i + 1) % responses.length);
      setTrigger(true);
    }, 50);
  };

  return (
    <div className="flex min-h-50 items-center justify-center px-6">
      <div className="w-full max-w-lg rounded-2xl border border-border bg-card p-6 shadow-sm">
        <div className="mb-3 flex items-center gap-2">
          <div className="h-6 w-6 rounded-full bg-linear-to-br from-violet-500 to-pink-500" />
          <span className="font-semibold text-muted-foreground text-xs">
            AI Assistant
          </span>
        </div>
        <TextGenerateEffect
          as="p"
          className="text-foreground text-sm leading-relaxed"
          filter
          key={index}
          staggerDuration={0.06}
          transition={{ duration: 0.4 }}
          trigger={trigger}
        >
          {responses[index]!}
        </TextGenerateEffect>
        <button
          className="mt-4 text-muted-foreground text-xs hover:text-foreground"
          onClick={regenerate}
          type="button"
        >
          ↺ Regenerate
        </button>
      </div>
    </div>
  );
}
```
