Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Textarea change cursor position when writing

I have a textarea and when I click to add some text it starts from the top left corner of the textarea and it seems ugly. Can I change the position where the cursor starts ?

<TextArea
  placeholder=' Type your comment here...' 
  value={comment}
  onChange={e => setComment(e.target.value)}
>
</TextArea>

I was able to change the position of placeholder the way below but not the cursor

::placeholder {
  color: #C8C8C8;
  position: absolute;
  left: 15px;
  top: 15px;
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use CSS to style a <textarea>. You can change the alignment of the text…

textarea {
  display: block;
  width: 100%;
  text-align: center;
}
<!--
borrowed from 
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
-->

<label for="story">Tell us your story:</label>

<textarea id="story" name="story"
          rows="5" cols="33">
It was a dark and stormy night...
</textarea>

Or add padding to the element:

textarea {
  display: block;
  width: 100%;
  padding: 15px;
}
<!--
borrowed from 
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea
-->

<label for="story">Tell us your story:</label>

<textarea id="story" name="story"
          rows="5" cols="33">
It was a dark and stormy night...
</textarea>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading