Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
  <body>
      <div id="app" class="w-100 bg-gray-100 pt-36 h-screen">
          <div class="flex m-auto max-w-3xl mb-6">
            <div>Some chat content</div>
          </div>
          <div class="flex m-auto max-w-3xl">
              <div ref="textAreaContainer" class="relative flex-grow items-center">
                  <textarea
                      placeholder="start typing"
                      ref="conversationTextArea"
                      rows="1"
                      class="absolute rounded border border-gray-300 px-3 py-2 resize-none w-full bottom-0 outline-none focus:border-blue-500 hover:border-blue-500"
                      :style="textareaInline"
                      @keyup.enter.exact="sendMessage"
                      @keyup="manageTextAreaHeight($event)"
                  >
                  </textarea>
              </div>
              <div class="flex items-center justify-center h-11 w-24 bg-blue-200 ml-2 rounded font-bold cursor-pointer hover:bg-blue-400">send ></div>
          </div>
      </div>
  </body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                var vm = new Vue({
    el: '#app',
    data() {
        return {
            textAreaMaxHeight: 0,
            textareaInline: {
                maxHeight: "30vh",
                overflow: "hidden",
                height: "2.75rem",
            },
        };
    },
    created() {
        window.addEventListener("resize", this.setTextAreaMax);
    },
    destroyed() {
        window.removeEventListener("resize", this.setTextAreaMax);
    },
    mounted() {
        this.setTextAreaMax();
    },
    methods: {
        setTextAreaMax() {
            let convTextArea = this.$refs.conversationTextArea;
            let compStyles = window.getComputedStyle(convTextArea);
            this.textAreaMaxHeight = compStyles.getPropertyValue("max-height");
        },
        manageTextAreaHeight(e) {
            let ele = e.target;
            this.textareaInline.height = "auto";

            Vue.nextTick(() => {
                this.textareaInline.height = ele.offsetHeight - 2 === ele.scrollHeight? "2.75rem": `${ele.scrollHeight + 10}px`;
                console.log(this.$refs.textAreaContainer)
                this.$refs.textAreaContainer.height = ele.scrollHeight + 10;

                let calcMaxHeight = parseInt(this.textAreaMaxHeight.replace("px", ""));
                if (ele.scrollHeight + 10 >= calcMaxHeight) {
                    this.textareaInline.overflow = "auto";
                } else {
                    this.textareaInline.overflow = "hidden";
                }
            });
        }
    }
});
              
            
!
999px

Console