question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

text-align in TextField is ignored

See original GitHub issue

Setting 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.

image

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?).

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Legiothcommented, Aug 10, 2018

@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 do tf.addThemeVariants(TextFieldVariant.LUMO_ALIGN_RIGHT);.

1reaction
web-padawancommented, Aug 10, 2018

When using Lumo theme, you should be setting theme to align-right, see https://vaadin.com/components/vaadin-text-field/html-examples/text-field-lumo-theme-demos

You 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found