text-align in TextField is ignored
See original GitHub issueSetting text-align on a TextField does nothing. If looked at with an object inspector (Chrome, …) it shows the style only applied to the vaadin-text-field “wrapper”, not to the input itself.
To reproduce just use the starter project and add a TextField with text-align set:
TextField tf = new TextField();
tf.setValue("should be aligned right");
tf.getStyle().set("text-align", "right");
The text inside will still be aligned left.
If you apply it to the input with an object inspector, the last characters will be greyed out (unless the field has focus - maybe interference by the suffix-slot?).
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Flutter - TextField "textAlign" property not found - Stack Overflow
So I went to the docs and it told me to use the textAlign property. new TextField( textAlign: TextAlign. center; style: new TextStyle(fontSize: ......
Read more >TextField class - material library - Flutter - Dart API docs
A Material Design text field. A text field lets the user enter text, either with hardware keyboard or with an onscreen keyboard. The...
Read more >TextField (deprecated) - Xojo documentation
A TextField control can contain one line of text, with one font, font size, ... property is not Nil, then any control's MouseCursor...
Read more >Text Alignment not Working | Apple Developer Forums
Hey, to center your text inside your text field you need to add the multilineTextAlignment modifier to it with center as argument. ......
Read more >textAlign() / Reference / Processing.org
When using text() with width and height parameters, BASELINE is ignored, and treated as TOP. (Otherwise, text would by default draw outside the...
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
@web-padawan Great. That’s way easier than any of the haxxors that I suggested!
Just to clarify, the Java code for doing this with Vaadin 10 would be
tf.getElement().setAttribute("theme", "align-right");
.In an upcoming version (tentatively Vaadin 12), this will be further simplified to
tf.addThemeName("align-right")
, or if you prefer to not have a magic string in your code, you can dotf.addThemeVariants(TextFieldVariant.LUMO_ALIGN_RIGHT);
.When using Lumo theme, you should be setting
theme
toalign-right
, see https://vaadin.com/components/vaadin-text-field/html-examples/text-field-lumo-theme-demosYou can also take a look at how theme is implemented: https://github.com/vaadin/vaadin-text-field/blob/bcc503f1bedf41f01b625d7b5e5fb4c32b02bb78/theme/lumo/vaadin-text-field-styles.html#L310
There is one trick related to text overflow, but apart from that, you should be able to extend theme module and apply CSS to the
[part=value]
as described in the above comment.