Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# textual-enhanced ChangeLog

## Unreleased

**Released: WiP**

- Added `password`, `suggester`, `title` and `sub_title` to `ModalInput`.
([#76](https://github.com/davep/textual-enhanced/pull/76))

## v1.5.0

**Released: 2026-05-22**
Expand Down
5 changes: 4 additions & 1 deletion src/textual_enhanced/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ async def input_action(self, message: Button.Pressed) -> None:
ModalInput(placeholder="Enter some text here")
if message.button.id == "input"
else ModalInput(
placeholder="This has an initial value", initial="Testing..."
placeholder="This has an initial value",
initial="Testing...",
title="This is a title",
sub_title="This is a subtitle",
)
):
self.notify(f"Entered '{text}")
Expand Down
28 changes: 27 additions & 1 deletion src/textual_enhanced/dialogs/modal_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from textual import on
from textual.app import ComposeResult
from textual.screen import ModalScreen
from textual.suggester import Suggester
from textual.widgets import Input


Expand Down Expand Up @@ -32,23 +33,48 @@ def __init__(
placeholder: str | None = None,
initial: str = "",
classes: str | None = None,
password: bool = False,
suggester: Suggester | None = None,
title: str | None = None,
sub_title: str | None = None,
) -> None:
"""Initialise the object.

Args:
placeholder: The placeholder text to use.
initial: The initial value for the input.
classes: The CSS classes of the modal input.
password: Whether the input is a password input.
suggester: The suggester to use for the input.
title: The title of the modal input.
sub_title: The subtitle of the modal input.
"""
super().__init__(classes=classes)
self._placeholder = placeholder or ""
"""The placeholder to use for the input."""
self._initial = initial
"""The initial value for the input."""
self._password = password
"""Whether the input is a password input."""
self._suggester = suggester
"""The suggester to use for the input."""
self._title = title
"""The title of the modal input."""
self._subtitle = sub_title
"""The subtitle of the modal input."""

def compose(self) -> ComposeResult:
"""Compose the input dialog."""
yield Input(self._initial, placeholder=self._placeholder)
yield (
control := Input(
self._initial,
placeholder=self._placeholder,
suggester=self._suggester,
password=self._password,
)
)
control.border_title = self._title
control.border_subtitle = self._subtitle

@on(Input.Submitted)
def accept_input(self) -> None:
Expand Down
Loading