Textarea breaks layout easily
See original GitHub issueTextarea input has no resize: none
CSS property set, so I’m able to resize it as much as I want.
It’s usually not what I want to because it will definitely break a website’s layout. Just try resizing “address” textarea on this demo page.
At least it should be locked horizontally and limited vertically.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Render Long Text Area Line Breaks in LWC
I am trying to display a long text area in a lightning web component with its line breaks. Unfortunately the "\n" characters are...
Read more >How do I preserve line breaks when getting text from a textarea?
The easiest solution is to simply style the element you're inserting the text into with the following CSS property: white-space: pre-wrap;.
Read more >How to add line breaks to an HTML textarea? - GeeksforGeeks
Approach: This task can be achieved by using some predefined array and string functions provided by JavaScript.
Read more >HTML - Textarea Wrap - Tizag Tutorials
"Hard" wraps the words inside the text box and places line breaks at the end of each line so that when the form...
Read more >textarea send new lines and spaces tutorial - YouTube
... breaks and multi spaces aren't sent with the textarea, in this video you will learn how to solve that problem using easy...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@alansouzati I think an excellent companion post to follow the above would be to take this Textarea resize issue and make it into a well-written tutorial that all can learn from.
Yes. I think it is a great idea to have
resize={true | false}
,resize='horizontal'
, andresize='vertical'
.You are raising a very good question, that probably deserves a blog post or something. This is key to understanding grommet. So, let me explain here first and then later I will wrap this up in a post.
There are a few places in Grommet that touch styling one way or another.
theme
objectProperties inside the theme affect all instances. You also might be asking how we decide to put things in the theme or not. That decision is on a component-by-component basis. Take Anchor for example. A common CSS property used in anchors is
textDecoration
and, when used, you want to apply that in all your anchor instances, otherwise your app is going to look inconsistent. This feels a great property to live insidetheme.anchor
and not as a property to Anchor. As a result, you will not see<Anchor textDecoration='none' />
. For customizing our components beyond the properties we added in the theme you can always rely on theextend
functionality (e.gtheme.anchor.extend
,theme.anchor.hover.extend
).props
The properties in our components are defined also based on a need basis. Using the anchor again as an example, we found the need of icons and labels, and logic to have them reversed. Or using just the icon, or just the label. We started as small as we could, and we are open to adding more properties for as long as we see a good use case for it. Your
resize
example was a great one where it is totally possible for a givenTextArea
to allow resizing whiles others don’t. This does not make sense to live in the theme, since it can change for different instances. It is also common enough that deserves a dedicated prop to it.Another great example of a prop that affects style is the
truncate
prop in Text. I often find people adding this boilerplate everywhere:we find it easier to do as follows:
<Text truncate>...</Text>
Conclusion
The decision where to put things is done based on interpreting the needs of each component. We are open to the suggestions from the community when to add new props or not, and where to add them. It is strongly advised to stick to the properties, avoiding the use of
style
. This feels like going in your own route and forgetting about the component’s initial intentions. We are totally open to try and understand why you think Box and Grid properties are not clear. This would help us understand the changes we need to make in order to have you dropstyle
. Of course this is your decision, if usingstyle
feels more natural to you, go for it. I just think it is harder to make things reusable that way, while still leveraging the theme entries.Finally, in certain situations, I find the CSS syntax for grid and flexbox very complicated to interpret. Let me show you an example:
Whenever I ask someone new to css grids to explain me what this piece of code is doing, they cannot explain it, especially
repeat(12,minmax(auto,1fr))
.I’ve had more success asking them to explain and interpret this:
This is almost self-explanatory: a grid with 12 columns that has a medium gap. Of course you can always do the pixel values:
But I see problems with this:
I hope this helps you understand where we are coming from. And, of course, we are open for feedback.