charmbracelet / huh

Build terminal forms and prompts 🤷🏻‍♀️
MIT License
3.72k stars 94 forks source link

feat: adjust input width to char limit #260

Closed nervo closed 1 month ago

nervo commented 1 month ago

When using non transparent background for char limited input text, the field weirdly fill all the layout view, resulting in a poor user interface experience.

In this example, CharLimit is set to 12:

Capture d’écran 2024-05-29 à 14 57 29

This pr adjusts its final width during the view time, letting the WithWidth method doing the hard job

And voila:

Capture d’écran 2024-05-29 à 15 07 35

And before you asks, yes it supports inline mode:

Capture d’écran 2024-05-29 à 15 22 37
maaslalani commented 1 month ago

Incredible work @nervo, thank you so much! I also really appreciate the attention to detail with inline mode screenshots too!