Skip to content

feat(tui-prompts): WIP Add DateTime type#92

Open
2910000 wants to merge 2 commits into
ratatui:mainfrom
2910000:num-date
Open

feat(tui-prompts): WIP Add DateTime type#92
2910000 wants to merge 2 commits into
ratatui:mainfrom
2910000:num-date

Conversation

@2910000

@2910000 2910000 commented Jul 29, 2025

Copy link
Copy Markdown
Contributor

This is a work in progress, but I thought this would be a good point to share what I have so far.

The DateTime prompt does most of what I want it to, and the trait changes relating to prompt state should make it easier to add other compound prompts (like a radio button prompt).

That said, working on this demonstrated just how opinionated a prompt that handles date and time has to be.
It may be less of a headache long-term to include the datetime module only in the examples directory, while keeping the code allowing compound state that it's built on.

Please let me know what you think!


What this changes

State traits

Creates a CompoundState, intended as a container to hold the state of multiple child prompts.
Creates a TextualState to hold functionality separate from the container-like CompoundState.
Creates a StateCommon, to hold core functionality shared by all state types.

Validation

  • per-character validation on input (is_valid_char)
  • checking value wrt native type (e.g. for DateTime, chrono::NaiveDateTime) on marking prompt Status as Done

datetime Module

DateTimeState, DateTimePrompt, NumericChildState and NumericPrompt

Styling

The datetime prompt has a default display shown when no text is entered.

Example

20250729_10h54m12s_grim

Adds the utc_time example, which requires the datetime feature:

$ cargo run --features datetime --example utc_time

The status doesn't do anything.

Remaining issues

I haven't written much documentation or any tests for the new code yet.

Validity

No builtin way of checking semantic validity yet.
This is important where the value of one prompt is related to the value of another, or where there is an external constraint.
Does it need to be builtin? I'm not sure

Status

With validation on submission, there is now the possibility for an "invalid" status. I have made no changes to this, so the Status (or more broadly, how status is considered and handled) needs review.

Adding Style

The *RenderStyle types would benefit from more generalisation.

Prompt Sizing

I haven't yet done anything to allow for resizing of the DateTimePrompt.

joshka commented Jun 11, 2026

Copy link
Copy Markdown
Member

Thanks for sharing this. Date is on the old tui-prompts TODO list, but I’m not actively using this crate myself right now, so my maintainer involvement here is fairly light.

My instinct is that this is too much surface area for the crate as-is. The datetime part may be better explored as a standalone widget/example first. The current UI also feels a bit literal/heavy to me, so I’d lean simpler there.

The larger prompt-state changes are probably worth a separate design discussion. The original tui-prompts API predates some newer Ratatui patterns like implementing Widget for &SomeStruct / &mut SomeStruct, so if we are changing the text prompt/state model, it may be a good time to involve other maintainers and revisit the underlying shape more deliberately.

I don’t think we should merge the current WIP directly, but I’d be open to a narrower follow-up around either the standalone date/datetime widget idea or a design issue for the prompt API changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants