Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

🐛 Text alignment in TextBox depends on placeholder #1027

Closed
robkri opened this issue Feb 21, 2024 · 1 comment · Fixed by #1175
Closed

🐛 Text alignment in TextBox depends on placeholder #1027

robkri opened this issue Feb 21, 2024 · 1 comment · Fixed by #1175
Labels
bug Something isn't working

Comments

@robkri
Copy link
Contributor

robkri commented Feb 21, 2024

The alignment of the text inside a TextBox changes depending on whether or not the TextBox is given a placeholder text. If any String is passed to placeholder (even an empty String), the text gets aligned vertically centered. Otherwise it's aligned at the top of the TextBox. This is barely recognizable in the first two examples where the difference is only about 1px, but shows very clearly when TextBox expands in a larger parent:
grafik

To reproduce

Column(
      children: [
        SizedBox(child: TextBox()),
        SizedBox(height: 16),
        SizedBox(child: TextBox(placeholder: "")),
        SizedBox(height: 16),
        SizedBox(height: 50, child: TextBox()),
        SizedBox(height: 16),
        SizedBox(height: 50, child: TextBox(placeholder: "")),
      ],
    )

Expected behaviour
The text inside a TextBox with maxLines = 1 is always vertically centered.

@bdlukaa
Copy link
Owner

bdlukaa commented Jan 30, 2025

You can define the text vertical alignment using the TextBox.textAlignVertical property.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants