ratatui_toolkit/primitives/button/constructors/new.rs
1use ratatui::style::{Color, Modifier, Style};
2
3use crate::primitives::button::Button;
4
5impl Button {
6 /// Creates a new button with the specified text.
7 ///
8 /// # Arguments
9 ///
10 /// * `text` - The button text to display
11 ///
12 /// # Returns
13 ///
14 /// A new `Button` instance with default styling
15 ///
16 /// # Example
17 ///
18 /// ```rust
19 /// use ratatui_toolkit::Button;
20 ///
21 /// let button = Button::new("Click Me");
22 /// ```
23 pub fn new(text: impl Into<String>) -> Self {
24 Self {
25 text: text.into(),
26 area: None,
27 hovered: false,
28 normal_style: Style::default()
29 .fg(Color::Cyan)
30 .add_modifier(Modifier::BOLD),
31 hover_style: Style::default()
32 .fg(Color::Black)
33 .bg(Color::Cyan)
34 .add_modifier(Modifier::BOLD),
35 }
36 }
37}