Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Alpine.js plugin to automatically resize a textarea to fit its content.

License

NotificationsYou must be signed in to change notification settings

marcreichel/alpine-autosize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A littleAlpine.js plugin to automatically resize atextarea to fit its content.

versionBuild sizedownloadsJSDelivrGitHub

🚀 Installation

CDN

Include the following<script> tag in the<head> of your document, just before Alpine.

<scriptsrc="https://cdn.jsdelivr.net/npm/@marcreichel/alpine-autosize@latest/dist/alpine-autosize.min.js"defer></script>

NPM

npm install @marcreichel/alpine-autosize

Add thex-autosize directive to your project by importing the packagebefore starting Alpine.

importAlpinefrom'alpinejs';importAutosizefrom'@marcreichel/alpine-autosize';Alpine.plugin(Autosize);Alpine.start();

🪄 Usage

Directive

To let thetextarea automatically resize, add thex-autosize directive to the<textarea>.

<textareax-autosize></textarea>

Magic

If you want to "manually" update the size of the textarea – for example after updating its content programatically – you may use the$autosize Alpine magic:

<divx-data="{ text: '' }"x-init="$watch('text', () => { $nextTick(() => { $autosize($refs.input); }); })"><textareax-ref="input"x-model="text"></textarea></div>

Just make sure, you call$autosize($refs.input) inside of a$nextTick for Alpine to update the DOM correctly.

📄 License

Copyright (c) 2022 - 2023 Marc Reichel and contributors.

Licensed under the MIT license, seeLICENSE for details.

About

Alpine.js plugin to automatically resize a textarea to fit its content.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp