Skip to main content

endpoint_validator/tui/widgets/
input.rs

1use ratatui::{
2    style::{Color, Style},
3    text::Span,
4    widgets::{Block, Borders, Paragraph},
5};
6
7pub fn create_input_widget<'a>(label: &'a str, value: &'a str, is_focused: bool) -> Paragraph<'a> {
8    let block = Block::default()
9        .borders(Borders::ALL)
10        .border_style(Style::default().fg(if is_focused {
11            Color::Yellow // Highlight border when focused
12        } else {
13            Color::Gray
14        }))
15        .title(Span::styled(
16            label,
17            Style::default().fg(if is_focused {
18                Color::Gray // Highlight title when focused
19            } else {
20                Color::Gray
21            }),
22        ));
23
24    Paragraph::new(value)
25        .style(Style::default().fg(Color::Gray))
26        .block(block)
27}