GithubHelp home page GithubHelp logo

usalmon / resize-textarea-vue3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dneshp/resize-textarea-vue3

0.0 0.0 0.0 25 KB

A simple textarea resize for Vue3.

License: MIT License

JavaScript 20.00% Vue 80.00%

resize-textarea-vue3's Introduction

Resize Textarea

A simple resize textarea for Vue3.

Inspired from vue-textarea-autosize (Works with Vue2)

Installation

Install the package using npm

npm install resize-textarea

Documentation

  1. Create a new Vue instance
  2. Import ResizeTextarea and use it
import { createApp } from 'vue'
import ResizeTextarea from 'resize-textarea-vue3'

const app = createApp({
  /* root component options */
})
app.use(ResizeTextarea)
.mount('#app')

Available props:

Props required type default
placeholder no String Null
rows no Number 2
cols no Number 0
minHeight no Number 50 px
maxHeight (The content will be scrollable after set limit) no Number Null
modelValue no String / Number Null
autoResize (The drag handle is disabled by default.) no Booolean true

The default unit is (px)


Component simple usage example:

<template>
    <div id="wrapper">
        <resize-textarea
        :placeholder="placeholder"
        :rows="2"
        :cols="4"
        :maxHeight="150"
        v-model="textValue">
        </resize-textarea>
    </div>
    <script>
    export default {
        data() {
            return {
                placeholder: "This is a test message",
                textValue: "reSize",
            }
        },
    }
    </script>
</template>

Component usage with update:modelValue event example:

<template>
    <div id="wrapper">
        <resize-textarea
        :placeholder="placeholder"
        :modelValue="textValue"
        @update:modelValue="(value)=>useUpdatedValue(value)"
        v-model="textValue">
        </resize-textarea>
    </div>
    <script>
    export default {
        data() {
            return {
                placeholder: "This is a test message",
                textValue: "reSize",
            }
        },
        methods: {
            useUpdatedValue(value) {
                //do something 
            }
        }
    }
    </script>
</template>

Component usage example with state management:

<template>
    <div id="wrapper">
        <resize-textarea
        :placeholder="placeholder"
        v-model="textValue">
        </resize-textarea>
    </div>
    <script>
    export default {
        data() {
            return {
                placeholder: "This is a test message",
            }
        },
        computed: {
            textValue: {
                get() {
                    return this.$store.state.textValue
                },
                set(v) {
                    this.$store.commit('UPDATE', v)
                }
            }
        }
    }
    </script>
</template>

resize-textarea-vue3's People

Contributors

dneshp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.