Skip to content

How do I right-align the text entered into an Input? #3661

Answered by davep
porridge asked this question in Q&A
Discussion options

You must be logged in to vote

As you've found, those styles don't affect the way Input displays its content; as of right now I don't believe there is a way to do what you're looking for. I think, if I were to do what you're doing, I'd wrap Input and make it size: auto, align it right in the container widget, and work from there. For example:

from textual.app import App, ComposeResult
from textual.widget import Widget
from textual.widgets import Input

class RightInput(Widget):

    DEFAULT_CSS = """
    RightInput {
        width: 1fr;
        height: auto;
        align-horizontal: right;
    }

    RightInput Input {
        width: auto;
    }
    """

    def compose(self) -> ComposeResult:
        yield Input()


c…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@porridge
Comment options

@porridge
Comment options

Answer selected by porridge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants