Skip to content

πŸŽ₯ Make videos programmatically with React

Update text-animations.md

Jonny Burger2d170b217fd0
diff --git a/packages/skills/skills/remotion/rules/text-animations.md b/packages/skills/skills/remotion/rules/text-animations.md
index 0b87b3f453..e38b1c5742 100644
--- a/packages/skills/skills/remotion/rules/text-animations.md
+++ b/packages/skills/skills/remotion/rules/text-animations.md
@@ -2,102 +2,19 @@
name: text-animations
description: Typography and text animation patterns for Remotion.
metadata:
- tags: typography, text, typewriter, kinetic, animation
+ tags: typography, text, typewriter, highlighter ken
---
-## Typewriter Effect - Use String Slicing
+## Text animations
-Always use string slicing for typewriter effects. Never use per-character opacity.
-
-**Incorrect (per-character opacity - breaks cursor positioning):**
-
-```tsx
-{
- text.split('').map((char, i) => <span style={{opacity: i < typedCount ? 1 : 0}}>{char}</span>);
-}
-<span>|</span>;
-```
-
-**Correct (string slicing - cursor follows text):**
-
-```tsx
-const typedText = FULL_TEXT.slice(0, typedChars);
-
-<span>{typedText}</span>
-<span style={{ opacity: caretOpacity }}>β–Œ</span>
-```
-
-## Cursor Blink - Use Smooth Interpolation
-
-Blinking cursors should fade smoothly, not flash on/off abruptly.
-
-**Incorrect (abrupt blink):**
-
-```tsx
-const caretVisible = Math.floor(frame / 15) % 2 === 0;
-<span style={{opacity: caretVisible ? 1 : 0}}>|</span>;
-```
-
-**Correct (smooth blink):**
-
-```tsx
-const CURSOR_BLINK_FRAMES = 16;
-const caretOpacity = interpolate(frame % CURSOR_BLINK_FRAMES, [0, CURSOR_BLINK_FRAMES / 2, CURSOR_BLINK_FRAMES], [1, 0, 1], {extrapolateLeft: 'clamp', extrapolateRight: 'clamp'});
+Based on `useCurrentFrame()`, reduce the string character by character to create a typewriter effect.
-<span style={{opacity: caretOpacity}}>β–Œ</span>;
-```
+## Typewriter Effect
-## Word Carousel - Stable Width Container
+See [Typewriter](assets/text-animations-typewriter.tsx) for an advanced example with a blinking cursor and a pause after the first sentence.
-Prevent layout shifts by using the longest word to set container width.
-
-**Incorrect (width jumps between words):**
-
-```tsx
-<div style={{position: 'relative'}}>
- <span>{WORDS[currentIndex]}</span>
-</div>
-```
-
-**Correct (stable width from longest word):**
-
-```tsx
-const longestWord = WORDS.reduce((a, b) => (a.length >= b.length ? a : b), WORDS[0]);
-
-<div style={{position: 'relative'}}>
- <div style={{visibility: 'hidden'}}>{longestWord}</div>
- <div style={{position: 'absolute', left: 0, top: 0}}>{WORDS[currentIndex]}</div>
-</div>;
-```
-
-## Text Highlight - Two Layer Crossfade
-
-Use overlapping layers for smooth highlight transitions.
-
-```tsx
-const typedOpacity = interpolate(frame, [highlightStart - 8, highlightStart + 8], [1, 0], {extrapolateLeft: 'clamp', extrapolateRight: 'clamp'});
-const finalOpacity = interpolate(frame, [highlightStart, highlightStart + 8], [0, 1], {extrapolateLeft: 'clamp', extrapolateRight: 'clamp'});
-
-{
- /* Typing layer */
-}
-<div style={{opacity: typedOpacity}}>{typedText}</div>;
-
-{
- /* Final layer with highlight */
-}
-<div style={{position: 'absolute', inset: 0, opacity: finalOpacity}}>
- <span>{preText}</span>
- <span style={{backgroundColor: COLOR_HIGHLIGHT}}>{HIGHLIGHT_WORD}</span>
- <span>{postText}</span>
-</div>;
-```
-
-## Complete Examples
+Always use string slicing for typewriter effects. Never use per-character opacity.
-For full working code examples, see:
+## Word Highlighting
-- [Typewriter](assets/text-animations-typewriter.tsx) - Typewriter effect with blinking cursor and dramatic pause
-- [Word Highlight](assets/text-animations-word-highlight.tsx) - Spring-animated highlight wipe on a word in a sentence
-- [Word Carousel](assets/text-animations-word-carousel.tsx) - Rotating words with crossfade and blur
-- [Text Rotation](assets/text-animations-text-rotation.tsx) - Rotating words with dissolve and blur effects
+See [Word Highlight](assets/text-animations-word-highlight.tsx) for an example for how a word highlight is animated, like with a highlighter pen.