|
| 1 | +# TypeIt - React |
| 2 | + |
| 3 | +The official React component for [TypeIt](https://github.com/alexmacarthur/typeit), the most versatile JavaScript animated typing utility on the planet. You can use it to bring dynamic typewriter effects to your React applications. |
| 4 | + |
| 5 | +## License Options |
| 6 | + |
| 7 | +Use this component in an open source or personal project for free. For commercial projects, the following licenses are available. A single license will cover use of this component, as well as TypeItJS itself. |
| 8 | + |
| 9 | +- Single Commercial License - [Purchase Here](https://typeitjs.com/checkout/limited) |
| 10 | +- Extended Commercial License - [Purchase Here](https://typeitjs.com/checkout/unlimited) |
| 11 | + |
| 12 | +## Usage |
| 13 | + |
| 14 | +### The Simplest Example |
| 15 | + |
| 16 | +In its simplest implementation, import the component and wrap some text to be typed. |
| 17 | + |
| 18 | +```js |
| 19 | +import TypeIt from "typeit-react"; |
| 20 | + |
| 21 | +export default () => { |
| 22 | + return ( |
| 23 | + <div className="App"> |
| 24 | + <TypeIt>This will be typed in a `span` element!</TypeIt> |
| 25 | + </div> |
| 26 | + ); |
| 27 | +}; |
| 28 | +``` |
| 29 | + |
| 30 | +Note: This approach will cause the string to first be rendered in the markup and _then_ picked up by TypeIt, which might be desired if you're using it with a statically rendered application (ex: GatsbyJS). However, it may also cause a brief flash of text when the page loads. For an alternative way to define strings, see below. |
| 31 | + |
| 32 | +### Customizing Your Options |
| 33 | + |
| 34 | +To tweak the animation to your liking, pass an object as the `options` prop. All options supported by TypeIt can be used here. Using this prop, you can also set strings without passing them as children. To view all options, see [TypeIt's documentation](https://typeitjs.com/docs#options). |
| 35 | + |
| 36 | +```javascript |
| 37 | +import TypeIt from "typeit-react"; |
| 38 | + |
| 39 | +export default () => { |
| 40 | + return ( |
| 41 | + <div className="App"> |
| 42 | + <TypeIt |
| 43 | + options={{ |
| 44 | + strings: ["This will be typed!"], |
| 45 | + speed: 10, |
| 46 | + waitUntilVisible: true |
| 47 | + }} |
| 48 | + /> |
| 49 | + </div> |
| 50 | + ); |
| 51 | +}; |
| 52 | +``` |
| 53 | + |
| 54 | +### Choose Your Own Element |
| 55 | + |
| 56 | +Out of the box, a `span` element is used to contain the typing animation. To choose your own element, use the `element` prop. |
| 57 | + |
| 58 | +```javascript |
| 59 | +import TypeIt from "typeit-react"; |
| 60 | + |
| 61 | +export default () => { |
| 62 | + return ( |
| 63 | + <div className="App"> |
| 64 | + <TypeIt element={"h3"}>This will be typed in an H3 tag.</TypeIt> |
| 65 | + </div> |
| 66 | + ); |
| 67 | +}; |
| 68 | +``` |
| 69 | + |
| 70 | +## Need Help? |
| 71 | + |
| 72 | +If you're working with a custom implementation of TypeIt and would like some help, I'm available for hire. [Get in touch!](https://macarthur.me/contact) |
| 73 | + |
| 74 | +## License |
| 75 | + |
| 76 | +[GPL-2.0](https://github.com/alexmacarthur/typeit/blob/master/LICENSE) © Alex MacArthur |
0 commit comments