Textarea
Bootstrap Textarea input free examples, templates & tutorial
Responsive Textarea with Bootstrap 5. How to change textarea height, size, width and style. Examples of textarea editor, comment, contact form, checkout & chat.
Basic textarea example
A basic example of a simple textarea input.
<div data-mdb-input-init class="form-outline">
<textarea class="form-control" id="textAreaExample1" rows="4"></textarea>
<label class="form-label" for="textAreaExample">Message</label>
</div>
Definition
A Bootstrap Textarea is an input dedicated to a large volume of text. It may be used in a variety of components like forms, comment sections, chats and forums.
Textarea can hold an unlimited number of characters, and the text renders in a fixed-width font.
The name
attribute is needed to reference the form data after the form is
submitted (if you omit the name
attribute, no data from the text area will be
submitted).
The id
attribute is needed to associate the text area with a label.
Textarea Height
To change the height of the textarea you need to change the value of the
rows
attribute.
<!-- Textarea 8 rows height -->
<div data-mdb-input-init class="form-outline">
<textarea class="form-control" id="textAreaExample2" rows="8"></textarea>
<label class="form-label" for="textAreaExample2">Message</label>
</div>
<!-- Textarea 2 rows height -->
<div data-mdb-input-init class="form-outline">
<textarea class="form-control" id="textAreaExample3" rows="2"></textarea>
<label class="form-label" for="textAreaExample3">Message</label>
</div>
Width
To change the width of the textarea use bootstrap sizing utilities or bootstrap grid system.
To learn more read Sizing docs.
Textarea with class .w-25
Textarea with class .w-50
Textarea with class .w-75
Textarea without sizing class
<!-- Textarea with class .w-25 -->
<div data-mdb-input-init class="form-outline w-25 mb-4">
<textarea class="form-control" id="textAreaExample4" rows="3"></textarea>
<label class="form-label" for="textAreaExample4">25% width of the parent</label>
</div>
<!-- Textarea with class .w-50 -->
<div data-mdb-input-init class="form-outline w-50 mb-4">
<textarea class="form-control" id="textAreaExample5" rows="3"></textarea>
<label class="form-label" for="textAreaExample5">50% width of the parent</label>
</div>
<!-- Textarea with class .w-75 -->
<div data-mdb-input-init class="form-outline w-75 mb-4">
<textarea class="form-control" id="textAreaExample6" rows="3"></textarea>
<label class="form-label" for="textAreaExample6">75% width of the parent</label>
</div>
<!-- Textarea without sizing class -->
<div data-mdb-input-init class="form-outline mb-4">
<textarea class="form-control" id="textAreaExample6" rows="3"></textarea>
<label class="form-label" for="textAreaExample6">100% width of the parent</label>
</div>
Usage examples
A few practical examples of textarea usage.
Contact form
A typical subscription form used when subscribing to a newsletter, asking a question in a FAQ section, or leaving a testimonial / review for a product.
<form>
<!-- Name input -->
<div data-mdb-input-init class="form-outline mb-4">
<input type="text" id="form4Example1" class="form-control" />
<label class="form-label" for="form4Example1">Name</label>
</div>
<!-- Email input -->
<div data-mdb-input-init class="form-outline mb-4">
<input type="email" id="form4Example2" class="form-control" />
<label class="form-label" for="form4Example2">Email address</label>
</div>
<!-- Message input -->
<div data-mdb-input-init class="form-outline mb-4">
<textarea class="form-control" id="form4Example3" rows="4"></textarea>
<label class="form-label" for="form4Example3">Message</label>
</div>
<!-- Checkbox -->
<div class="form-check d-flex justify-content-center mb-4">
<input class="form-check-input me-2" type="checkbox" value="" id="form4Example4" checked />
<label class="form-check-label" for="form4Example4">
Send me a copy of this message
</label>
</div>
<!-- Submit button -->
<button type="submit" data-mdb-button-init data-mdb-ripple-init class="btn btn-primary btn-block mb-4">
Send
</button>
</form>
Checkout form
An example of the extended form with typical checkout inputs like address form or a credit card form. You will probably encounter a textarea used like this during the checkout or shopping cart steps while using eCommerce websites.
<form>
<!-- 2 column grid layout with text inputs for the first and last names -->
<div class="row mb-4">
<div class="col">
<div data-mdb-input-init class="form-outline">
<input type="text" id="form6Example1" class="form-control" />
<label class="form-label" for="form6Example1">First name</label>
</div>
</div>
<div class="col">
<div data-mdb-input-init class="form-outline">
<input type="text" id="form6Example2" class="form-control" />
<label class="form-label" for="form6Example2">Last name</label>
</div>
</div>
</div>
<!-- Text input -->
<div data-mdb-input-init class="form-outline mb-4">
<input type="text" id="form6Example3" class="form-control" />
<label class="form-label" for="form6Example3">Company name</label>
</div>
<!-- Text input -->
<div data-mdb-input-init class="form-outline mb-4">
<input type="text" id="form6Example4" class="form-control" />
<label class="form-label" for="form6Example4">Address</label>
</div>
<!-- Email input -->
<div data-mdb-input-init class="form-outline mb-4">
<input type="email" id="form6Example5" class="form-control" />
<label class="form-label" for="form6Example5">Email</label>
</div>
<!-- Number input -->
<div data-mdb-input-init class="form-outline mb-4">
<input type="number" id="form6Example6" class="form-control" />
<label class="form-label" for="form6Example6">Phone</label>
</div>
<!-- Message input -->
<div data-mdb-input-init class="form-outline mb-4">
<textarea class="form-control" id="form6Example7" rows="4"></textarea>
<label class="form-label" for="form6Example7">Additional information</label>
</div>
<!-- Checkbox -->
<div class="form-check d-flex justify-content-center mb-4">
<input class="form-check-input me-2" type="checkbox" value="" id="form6Example8" checked />
<label class="form-check-label" for="form6Example8">
Create an account?
</label>
</div>
<!-- Submit button -->
<button type="submit" data-mdb-button-init data-mdb-ripple-init class="btn btn-primary btn-block mb-4">
Place order
</button>
</form>
Simple comment card
Textarea usage in a comment under the post on a social newsfeed.
<section style="background-color: #eee;">
<div class="container my-5 py-5">
<div class="row d-flex justify-content-center">
<div class="col-md-12 col-lg-10 col-xl-8">
<div class="card">
<div class="card-body">
<div class="d-flex flex-start align-items-center">
<img class="rounded-circle shadow-1-strong me-3"
src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/img%20(19).webp" alt="avatar" width="60"
height="60" />
<div>
<h6 class="fw-bold text-primary mb-1">
Lily Coleman
</h6>
<p class="text-muted small mb-0">
Shared publicly - Jan 2020
</p>
</div>
</div>
<p class="mt-3 mb-4 pb-2">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
consequat.
</p>
<div class="small d-flex justify-content-start">
<a href="#!" class="d-flex align-items-center me-3">
<i class="far fa-thumbs-up me-2"></i>
<p class="mb-0">Like</p>
</a>
<a href="#!" class="d-flex align-items-center me-3">
<i class="far fa-comment-dots me-2"></i>
<p class="mb-0">Comment</p>
</a>
<a href="#!" class="d-flex align-items-center me-3">
<i class="fas fa-share me-2"></i>
<p class="mb-0">Share</p>
</a>
</div>
</div>
<div class="card-footer py-3 border-0" style="background-color: #f8f9fa;">
<div class="d-flex flex-start w-100">
<img class="rounded-circle shadow-1-strong me-3"
src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/img%20(19).webp" alt="avatar" width="40"
height="40" />
<div data-mdb-input-init class="form-outline w-100">
<textarea class="form-control" id="textAreaExample" rows="4"
style="background: #fff;"></textarea>
<label class="form-label" for="textAreaExample">Message</label>
</div>
</div>
<div class="float-end mt-2 pt-1">
<button type="button" data-mdb-button-init data-mdb-ripple-init class="btn btn-primary btn-sm">
Post comment
</button>
<button type="button" data-mdb-button-init data-mdb-ripple-init class="btn btn-outline-primary btn-sm">
Cancel
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
Add a comment
A simple review comment with a star rating.
Add a comment
<section style="background-color: #d94125;">
<div class="container my-5 py-5 text-dark">
<div class="row d-flex justify-content-center">
<div class="col-md-10 col-lg-8 col-xl-6">
<div class="card">
<div class="card-body p-4">
<div class="d-flex flex-start w-100">
<img class="rounded-circle shadow-1-strong me-3"
src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/img%20(21).webp" alt="avatar" width="65"
height="65" />
<div class="w-100">
<h5>Add a comment</h5>
<ul data-mdb-rating-init class="rating mb-3" data-mdb-toggle="rating">
<li>
<i class="far fa-star fa-sm text-danger" title="Bad"></i>
</li>
<li>
<i class="far fa-star fa-sm text-danger" title="Poor"></i>
</li>
<li>
<i class="far fa-star fa-sm text-danger" title="OK"></i>
</li>
<li>
<i class="far fa-star fa-sm text-danger" title="Good"></i>
</li>
<li>
<i class="far fa-star fa-sm text-danger" title="Excellent"></i>
</li>
</ul>
<div data-mdb-input-init class="form-outline">
<textarea class="form-control" id="textAreaExample" rows="4"></textarea>
<label class="form-label" for="textAreaExample">What is your view?</label>
</div>
<div class="d-flex justify-content-between mt-3">
<button type="button" data-mdb-button-init data-mdb-ripple-init class="btn btn-success">
Danger
</button>
<button type="button" data-mdb-button-init data-mdb-ripple-init class="btn btn-danger">
Send
<i class="fas fa-long-arrow-alt-right ms-1"></i>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
Chat
Message textarea inside of a chat UI.
Member
-
John Doe
Hello, Are you there?
Just now
1 -
Danny Smith
Lorem ipsum dolor sit.
5 mins ago
-
Alex Steward
Lorem ipsum dolor sit.
Yesterday
-
Ashley Olsen
Lorem ipsum dolor sit.
Yesterday
-
Kate Moss
Lorem ipsum dolor sit.
Yesterday
-
Lara Croft
Lorem ipsum dolor sit.
Yesterday
-
Brad Pitt
Lorem ipsum dolor sit.
5 mins ago
-
Brad Pitt
12 mins ago
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-
Lara Croft
13 mins ago
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium.
-
Brad Pitt
10 mins ago
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
-
<section class="gradient-custom">
<div class="container py-5">
<div class="row">
<div class="col-md-6 col-lg-5 col-xl-5 mb-4 mb-md-0">
<h5 class="font-weight-bold mb-3 text-center text-white">
Member
</h5>
<div class="card mask-custom">
<div class="card-body">
<ul class="list-unstyled mb-0">
<li class="p-2 border-bottom"
style="border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;">
<a href="#!" class="d-flex justify-content-between link-light">
<div class="d-flex flex-row">
<img src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/avatar-8.webp" alt="avatar"
class="rounded-circle d-flex align-self-center me-3 shadow-1-strong" width="60" />
<div class="pt-1">
<p class="fw-bold mb-0">
John Doe
</p>
<p class="small text-white">
Hello, Are you there?
</p>
</div>
</div>
<div class="pt-1">
<p class="small text-white mb-1">
Just now
</p>
<span class="badge bg-danger float-end">1</span>
</div>
</a>
</li>
<li class="p-2 border-bottom"
style="border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;">
<a href="#!" class="d-flex justify-content-between link-light">
<div class="d-flex flex-row">
<img src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/avatar-1.webp" alt="avatar"
class="rounded-circle d-flex align-self-center me-3 shadow-1-strong" width="60" />
<div class="pt-1">
<p class="fw-bold mb-0">
Danny Smith
</p>
<p class="small text-white">
Lorem ipsum dolor sit.
</p>
</div>
</div>
<div class="pt-1">
<p class="small text-white mb-1">
5 mins ago
</p>
</div>
</a>
</li>
<li class="p-2 border-bottom"
style="border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;">
<a href="#!" class="d-flex justify-content-between link-light">
<div class="d-flex flex-row">
<img src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/avatar-2.webp" alt="avatar"
class="rounded-circle d-flex align-self-center me-3 shadow-1-strong" width="60" />
<div class="pt-1">
<p class="fw-bold mb-0">
Alex Steward
</p>
<p class="small text-white">
Lorem ipsum dolor sit.
</p>
</div>
</div>
<div class="pt-1">
<p class="small text-white mb-1">
Yesterday
</p>
</div>
</a>
</li>
<li class="p-2 border-bottom"
style="border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;">
<a href="#!" class="d-flex justify-content-between link-light">
<div class="d-flex flex-row">
<img src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/avatar-3.webp" alt="avatar"
class="rounded-circle d-flex align-self-center me-3 shadow-1-strong" width="60" />
<div class="pt-1">
<p class="fw-bold mb-0">
Ashley Olsen
</p>
<p class="small text-white">
Lorem ipsum dolor sit.
</p>
</div>
</div>
<div class="pt-1">
<p class="small text-white mb-1">
Yesterday
</p>
</div>
</a>
</li>
<li class="p-2 border-bottom"
style="border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;">
<a href="#!" class="d-flex justify-content-between link-light">
<div class="d-flex flex-row">
<img src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/avatar-4.webp" alt="avatar"
class="rounded-circle d-flex align-self-center me-3 shadow-1-strong" width="60" />
<div class="pt-1">
<p class="fw-bold mb-0">
Kate Moss
</p>
<p class="small text-white">
Lorem ipsum dolor sit.
</p>
</div>
</div>
<div class="pt-1">
<p class="small text-white mb-1">
Yesterday
</p>
</div>
</a>
</li>
<li class="p-2 border-bottom"
style="border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;">
<a href="#!" class="d-flex justify-content-between link-light">
<div class="d-flex flex-row">
<img src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/avatar-5.webp" alt="avatar"
class="rounded-circle d-flex align-self-center me-3 shadow-1-strong" width="60" />
<div class="pt-1">
<p class="fw-bold mb-0">
Lara Croft
</p>
<p class="small text-white">
Lorem ipsum dolor sit.
</p>
</div>
</div>
<div class="pt-1">
<p class="small text-white mb-1">
Yesterday
</p>
</div>
</a>
</li>
<li class="p-2">
<a href="#!" class="d-flex justify-content-between link-light">
<div class="d-flex flex-row">
<img src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/avatar-6.webp" alt="avatar"
class="rounded-circle d-flex align-self-center me-3 shadow-1-strong" width="60" />
<div class="pt-1">
<p class="fw-bold mb-0">
Brad Pitt
</p>
<p class="small text-white">
Lorem ipsum dolor sit.
</p>
</div>
</div>
<div class="pt-1">
<p class="small text-white mb-1">
5 mins ago
</p>
<span class="text-white float-end"><i class="fas fa-check"
aria-hidden="true"></i></span>
</div>
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="col-md-6 col-lg-7 col-xl-7">
<ul class="list-unstyled text-white">
<li class="d-flex justify-content-between mb-4">
<img src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/avatar-6.webp" alt="avatar"
class="rounded-circle d-flex align-self-start me-3 shadow-1-strong" width="60" />
<div class="card mask-custom">
<div class="card-header d-flex justify-content-between p-3"
style="border-bottom: 1px solid rgba(255, 255, 255, 0.3);">
<p class="fw-bold mb-0">Brad Pitt</p>
<p class="text-light small mb-0">
<i class="far fa-clock"></i> 12 mins ago
</p>
</div>
<div class="card-body">
<p class="mb-0">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
</div>
</li>
<li class="d-flex justify-content-between mb-4">
<div class="card mask-custom w-100">
<div class="card-header d-flex justify-content-between p-3"
style="border-bottom: 1px solid rgba(255, 255, 255, 0.3);">
<p class="fw-bold mb-0">Lara Croft</p>
<p class="text-light small mb-0">
<i class="far fa-clock"></i> 13 mins ago
</p>
</div>
<div class="card-body">
<p class="mb-0">
Sed ut perspiciatis unde omnis iste natus error sit voluptatem
accusantium doloremque laudantium.
</p>
</div>
</div>
<img src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/avatar-5.webp" alt="avatar"
class="rounded-circle d-flex align-self-start ms-3 shadow-1-strong" width="60" />
</li>
<li class="d-flex justify-content-between mb-4">
<img src="https://mdbcdn.b-cdn.net/img/Photos/Avatars/avatar-6.webp" alt="avatar"
class="rounded-circle d-flex align-self-start me-3 shadow-1-strong" width="60" />
<div class="card mask-custom">
<div class="card-header d-flex justify-content-between p-3"
style="border-bottom: 1px solid rgba(255, 255, 255, 0.3);">
<p class="fw-bold mb-0">Brad Pitt</p>
<p class="text-light small mb-0">
<i class="far fa-clock"></i> 10 mins ago
</p>
</div>
<div class="card-body">
<p class="mb-0">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
</div>
</li>
<li class="mb-3">
<div data-mdb-input-init class="form-outline form-white">
<textarea class="form-control" id="textAreaExample" rows="4"></textarea>
<label class="form-label" for="textAreaExample">Message</label>
</div>
</li>
<button type="button" data-mdb-button-init data-mdb-ripple-init class="btn btn-light btn-lg btn-rounded float-end">
Send
</button>
</ul>
</div>
</div>
</div>
</section>
.gradient-custom {
/* fallback for old browsers */
background: #fccb90;
/* Chrome 10-25, Safari 5.1-6 */
background: -webkit-linear-gradient(to bottom right, rgba(252, 203, 144, 1), rgba(213, 126, 235, 1));
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
background: linear-gradient(to bottom right, rgba(252, 203, 144, 1), rgba(213, 126, 235, 1))
}
.mask-custom {
background: rgba(24, 24, 16, .2);
border-radius: 2em;
backdrop-filter: blur(15px);
border: 2px solid rgba(255, 255, 255, 0.05);
background-clip: padding-box;
box-shadow: 10px 10px 10px rgba(46, 54, 68, 0.03);
}