# AnimatedText

Text that appears by word or character while remaining accessible.

## How to use it

children must be a string. split="words" is the default; stagger sets the timing offset in milliseconds. Use replayKey to replay. The complete sentence is exposed to accessibility while visual fragments are hidden from screen readers.

Character splitting uses Unicode code points, not graphemes. Use words for compound emoji or scripts with ligatures. Keep a semantic heading or paragraph around the component.

## Import


```tsx
import { AnimatedText } from "@kivora/nextjs";
```


Examples run in a Client Component. Also import the hooks, icons and dependencies used. This is the web API; consult the native guide for React Native.

## Example


```tsx
function Example() {
  const [replay, setReplay] = useState(0);
  return <div style={{ display: "grid", gap: 20 }}>
    <h2><AnimatedText split="words" preset="fade-up" duration={400} stagger={80} replayKey={replay}>Your next idea, in motion.</AnimatedText></h2>
    <Button type="button" variant="outline" onClick={() => setReplay(replay + 1)}>Replay animation</Button>
  </div>;
}
```


## By characters

```tsx
function Example() {
  const [replay, setReplay] = useState(0);
  return <div style={{ display: "grid", gap: 20 }}>
    <h2><AnimatedText split="characters" preset="fade-up" duration={400} stagger={40} replayKey={replay}>Your next idea, in motion.</AnimatedText></h2>
    <Button type="button" variant="outline" onClick={() => setReplay(replay + 1)}>Replay animation</Button>
  </div>;
}
```


## Without motion

```tsx
<AnimatedText disabled>Visible content without motion</AnimatedText>
```


## API: AnimatedText


```typescript
declare function AnimatedText({ children, split, preset, stagger, duration, delay, replayKey, disabled, ...props }: AnimatedTextProps): React.JSX.Element;
```


| Property | Type | Required | Description |
| --- | --- | --- | --- |
| children | string | Yes | Content or child elements of the component. |
| aria-label | string | No | Accessible name of the control. |
| className | string | No | Additional CSS classes to customize the element. |
| defaultChecked | boolean | No | Initial selection of the control. |
| defaultValue | string \| number \| readonly string[] | No | Initial value when the component manages its own state. |
| delay | number | No | Delay before the entrance, in milliseconds. |
| disabled | boolean | No | Disable control interaction or animation motion. |
| duration | number | No | Animation duration in milliseconds. |
| id | string | No | Element identifier; associates labels and descriptions. |
| onChange | ChangeEventHandler<HTMLSpanElement, Element> | No | Change event. Check the type: some controls return an object, others a DOM event. |
| onClick | MouseEventHandler<HTMLSpanElement> | No | Action performed when the element is activated. |
| onSubmit | SubmitEventHandler<HTMLSpanElement> | No | Form submission event. |
| preset | "fade" \| "fade-up" \| "fade-down" \| "scale" | No | Entrance effect: fade, fade-up, fade-down, or scale. |
| replayKey | string \| number | No | Change this value to replay the entrance animation. |
| role | AriaRole | No | Semantic role of the element. Keep the default role unless a change is justified. |
| split | "words" \| "characters" | No | Split text into words or Unicode code points. |
| stagger | number | No | Timing offset between text fragments, in milliseconds. |
| style | CSSProperties | No | React inline styles. |
| tabIndex | number | No | Keyboard focus order and availability. |
| title | string | No | Title or supplementary information. |

Source: https://www.kivora.pro/docs/componentes/animated-text
