autosize.mdx 994 B

12345678910111213141516171819202122232425
  1. ---
  2. title: Autosize
  3. summary: The autosize element will automatically adjust the textarea height and make it easier for users to follow as they type.
  4. libs: autosize
  5. description: Auto-adjusting textarea for better usability.
  6. ---
  7. To be able to use the autosize in your application you will need to install the autosize dependency with `npm install autosize`.
  8. ## Default markup
  9. Add the autosize element to your input to make it automatically adjust to the length of a text as a user types it.
  10. To create autosize textarea, add the `data-bs-toggle="autosize"` attribute to the textarea element:
  11. ```html
  12. <textarea class="form-control" data-bs-toggle="autosize" placeholder="Type something…"></textarea>
  13. ```
  14. Look at the example below to see how the autosize element works:
  15. ```html example centered columns={1} scrollable height="20rem"
  16. <label class="form-label">Autosize example</label>
  17. <textarea class="form-control" data-bs-toggle="autosize" placeholder="Type something…"></textarea>
  18. ```