UNPKG

@rusyar/react-typewriter

Version:

A React component with simple typewriting animation

35 lines (30 loc) 1.19 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; declare const useSyncState: (total?: number) => { turn: number; next: (order: number) => void; total: number | undefined; isLastTurn: boolean; }; type UseSyncState = typeof useSyncState; type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>; type Range<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>> | T; interface TypewriterProps { text: string; tagName?: 'h1' | 'h2' | 'h3' | 'p' | 'span'; size?: string; fontFamily?: string; weight?: Range<100, 900>; color?: string; speed?: number; delay?: number; cursorAnimation?: 'blink' | 'expand'; cursorColor?: string; cursorType?: 'line' | 'block'; sync?: { order: number; syncState: ReturnType<UseSyncState>; }; } declare const Typewriter: ({ text, tagName, size, fontFamily, weight, color, speed, delay, cursorAnimation, cursorColor, cursorType, sync, }: TypewriterProps) => react_jsx_runtime.JSX.Element; export { Typewriter, useSyncState }; export type { TypewriterProps, UseSyncState };