Typewriter Component โ โ
๐ Warning
XMarkdown Component
has been released and can be used in combination with the Typewriter Component
. Please upgrade to version beta 1.2.2
.
๐ Info
v1.2.0 version
provides simple solutions for style override, chart rendering, and custom code highlighting styles, custom plugins
We've added the official
prismjs
CSS style file to the component library, which can be directly imported in projects to solve md code block highlighting issues.We've added
Mermaid.js
to the component library. Used to solve simple chart rendering issues withmermaid format
.We've exposed the code highlighting methods and plugins built into
markdown-it
. Making it easier for developers to better integrate third-party ecosystem styles and plugins
๐ต This friendly reminder update time: 2025-07-06
Introduction โ
Typewriter
is a highly customizable typewriter component
, inspired by the ant-design-x
official bubble component
case, extracting the typing method. Supports Markdown rendering and dynamic typing effects.
Code Examples โ
Basic Usage โ
Markdown Rendering โ
MD-Code Block Highlighting (v1.2.0 New) โ
Provides a built-in style
MD-Plugin Mode (v1.2.0 New) โ
If you think the built-in styles don't look good or the built-in plugins can't meet your needs, you can customize styles and plugins through plugin mode.
Enable Typing Effect โ
Typewriter Fog Effect โ
Dynamic Content Updates โ
Control Typing โ
Attributes โ
Attribute | Type | Required | Default | Description |
---|---|---|---|---|
content | String | No | '' | Text content to display, supports plain text or Markdown format. |
isMarkdown | Boolean | No | false | Whether to enable Markdown rendering mode. |
typing | Boolean | { step?: number, interval?: number, suffix?: string } | No | false | Whether to enable typewriter effect. |
typing.step | Number | No | 2 | How many characters to type each time. |
typing.interval | Number | No | 50 | Interval time for each typing, unit (ms ). |
typing.suffix | String | No | '|' | Typewriter suffix cursor character (only effective in non-Markdown mode). |
isFog | Boolean | { bgColor?: string, width?: string } | No | false | Whether to enable fog effect, can set background color and width. |
Events โ
Event Name | Parameters | Type | Description |
---|---|---|---|
@start | ref instance | Function | Triggered when typing effect starts |
@finish | ref instance | Function | Triggered when typing effect completes |
@writing | ref instance | Function | Continuously triggered during typing effect |
Ref Instance Methods โ
Property Name | Type | Description |
---|---|---|
interrupt | Function | Interrupt typing. |
continue | Function | Continue unfinished typing. |
restart | Function | Restart typing. |
destroy | Function | Actively destroy typewriter component. |
renderedContent | String | Get the rendered content of the typewriter component. |
isTyping | Boolean | Whether currently typing. |
progress | Number | Typing progress, range 0 - 100. |
Features โ
- Markdown Support: Supports rendering Markdown format text and applies GitHub-style styling.
- Dynamic Typing Effect: Can simulate typewriter effect, gradually displaying text content.
- Code Highlighting: Built-in Prism.js, supports syntax highlighting for code blocks.
- XSS Security: Uses DOMPurify to filter HTML content, preventing XSS attacks.
- Flexible Configuration: Supports custom typing speed, cursor character, suffix, and other parameters.
- Customizable Development: Supports customized development based on component typing state.