css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <main class="scene">
  <div class="actor">
    <div class="actor__prefix">-</div>
    <div id="vader" class="actor__content"></div>

  <div class="actor">
    <div class="actor__prefix">-</div>
    <div id="luke" class="actor__content"></div>

  <p>This is a demo of <a href="https://github.com/Zhouzi/TheaterJS" target="_blank">TheaterJS</a>.</p>
  <p>It's forkable/editable on <a href="https://codepen.io/Zhouzi/pen/JoRazP" target="_blank">CodePen</a>.</p>
  <p>Everything you need to know is on its <a href="https://github.com/Zhouzi/TheaterJS" target="_blank">GitHub</a> repository.</p>
  <p>And it'd be really nice to share the force on <a href="https://twitter.com/home?status=TheaterJS%2C%20a%20typing%20effect%20mimicking%20human%20behavior.%20https%3A%2F%2Fgithub.com%2FZhouzi%2FTheaterJS%20via%20%40zh0uzi" target="_blank">Twitter</a> or <a href="https://www.facebook.com/sharer/sharer.php?u=https://github.com/Zhouzi/TheaterJS" target="_blank">Facebook</a>.</p>
              @import '//fonts.googleapis.com/css?family=Cutive';

$font-family-base: 'Cutive', serif;;
$font-size-root: 14px;
$font-size-base: 1rem;
$line-height-base: 1.4;

$color-black: #222;
$color-white: #ededed;
$color-red: #c92b2b;

$spacing: 2rem;
$spacing-large: $spacing * 3;

*:after {
  box-sizing: inherit;

body {
  padding: 0;
  margin: 0;

html {
  font-size: $font-size-root;
  height: 100%;
  box-sizing: border-box;

body {
  font-family: $font-family-base;
  font-size: $font-size-base;
  line-height: $line-height-base;
  color: $color-black;
  background-color: $color-white;
    background-color 150ms ease-out,
    color 150ms ease-out;

.dark {
  color: $color-white;
  background-color: $color-black;

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid;

  &:hover {
    box-shadow: inset 0 -8px 0 $color-red;

p {
  opacity: .6;
  margin: 0 0 .6rem 0;
  transition: opacity 300ms ease-out;

  &:hover {
    opacity: 1;

.scene {
  padding: $spacing-large $spacing;
  max-width: 800px;
  margin: 0 auto;

.actor {
  font-size: 2.8rem;
  display: flex;
  margin-bottom: $spacing;

  &:last-of-type {
    margin-bottom: $spacing-large;

.actor__content {
  flex-grow: 1;

@keyframes blink {
  from { opacity: 0; }
  to { opacity: 1; }

.actor__content--typing::after {
  content: '|';
  animation: blink 500ms infinite;
 * TheaterJS, a typing effect mimicking human behavior.
 * Github repository: 
 * https://github.com/Zhouzi/TheaterJS

var theater = theaterJS()

  .on('type:start, erase:start', function () {
  .on('type:end, erase:end', function () {
  .on('type:start, erase:start', function () {
    if (theater.getCurrentActor().name === 'vader') {
    } else {

  .addActor('vader', { speed: 0.8, accuracy: 0.6 })
  .addScene('vader:Luke.', 600)
  .addScene('luke:What?', 400)
  .addScene('vader:I am your father.', 400)
  .addScene('luke:Nooo...', -3, '!!! ', 600, 'No! ', 600)
  .addScene('luke:That\'s not true!', 600)
  .addScene('luke:That\'s impossible!', 400)
  .addScene('vader:Search your feelings.', 1600)
  .addScene('vader:You know it to be true.', 1000)
  .addScene('luke:Noooooooo! ', 600, 'No!', 400)
  .addScene('vader:Luke.', 600)
  .addScene('vader:You can destroy the Emperor.', 1600)
  .addScene('vader:He has foreseen this. ', 800)
  .addScene('vader:It is your destiny.', 1600)
  .addScene('vader:Join me.', 800)
  .addScene('vader:Together we can rule the galaxy.', 800)
  .addScene('vader:As father and son.', 1600)
  .addScene('vader:Come with me. ', 800)
  .addScene('vader:It is the only way.', 2000)
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................