1use ratatui::style::{Color, Modifier, Style};
4
5#[derive(Debug, Clone)]
7pub struct FormStyle {
8 pub title: Style,
10 pub label: Style,
12 pub label_focused: Style,
14 pub input: Style,
16 pub input_focused: Style,
18 pub placeholder: Style,
20 pub error: Style,
22 pub button: Style,
24 pub button_focused: Style,
26 pub border: Style,
28 pub border_focused: Style,
30}
31
32impl Default for FormStyle {
33 fn default() -> Self {
34 Self {
35 title: Style::default()
36 .fg(Color::Cyan)
37 .add_modifier(Modifier::BOLD),
38 label: Style::default().fg(Color::White),
39 label_focused: Style::default()
40 .fg(Color::Cyan)
41 .add_modifier(Modifier::BOLD),
42 input: Style::default().fg(Color::White).bg(Color::DarkGray),
43 input_focused: Style::default().fg(Color::White).bg(Color::Blue),
44 placeholder: Style::default().fg(Color::Gray),
45 error: Style::default().fg(Color::Red),
46 button: Style::default().fg(Color::White).bg(Color::DarkGray),
47 button_focused: Style::default()
48 .fg(Color::Black)
49 .bg(Color::Green)
50 .add_modifier(Modifier::BOLD),
51 border: Style::default().fg(Color::Gray),
52 border_focused: Style::default().fg(Color::Cyan),
53 }
54 }
55}
56
57impl FormStyle {
58 pub fn new() -> Self {
60 Self::default()
61 }
62
63 pub fn title(mut self, style: Style) -> Self {
65 self.title = style;
66 self
67 }
68
69 pub fn label(mut self, style: Style) -> Self {
71 self.label = style;
72 self
73 }
74
75 pub fn label_focused(mut self, style: Style) -> Self {
77 self.label_focused = style;
78 self
79 }
80
81 pub fn input(mut self, style: Style) -> Self {
83 self.input = style;
84 self
85 }
86
87 pub fn input_focused(mut self, style: Style) -> Self {
89 self.input_focused = style;
90 self
91 }
92
93 pub fn placeholder(mut self, style: Style) -> Self {
95 self.placeholder = style;
96 self
97 }
98
99 pub fn error(mut self, style: Style) -> Self {
101 self.error = style;
102 self
103 }
104
105 pub fn button(mut self, style: Style) -> Self {
107 self.button = style;
108 self
109 }
110
111 pub fn button_focused(mut self, style: Style) -> Self {
113 self.button_focused = style;
114 self
115 }
116
117 pub fn dark() -> Self {
119 Self::default()
120 }
121
122 pub fn light() -> Self {
124 Self {
125 title: Style::default()
126 .fg(Color::Blue)
127 .add_modifier(Modifier::BOLD),
128 label: Style::default().fg(Color::Black),
129 label_focused: Style::default()
130 .fg(Color::Blue)
131 .add_modifier(Modifier::BOLD),
132 input: Style::default().fg(Color::Black).bg(Color::White),
133 input_focused: Style::default().fg(Color::Black).bg(Color::LightBlue),
134 placeholder: Style::default().fg(Color::DarkGray),
135 error: Style::default().fg(Color::Red),
136 button: Style::default().fg(Color::Black).bg(Color::White),
137 button_focused: Style::default()
138 .fg(Color::White)
139 .bg(Color::Blue)
140 .add_modifier(Modifier::BOLD),
141 border: Style::default().fg(Color::DarkGray),
142 border_focused: Style::default().fg(Color::Blue),
143 }
144 }
145}