ratatui_toolkit/primitives/button/methods/
render_with_title.rs

1use ratatui::layout::Rect;
2use ratatui::text::Line;
3use ratatui::text::Span;
4
5use crate::primitives::button::Button;
6
7impl Button {
8    /// Renders the button alongside a title line.
9    ///
10    /// # Arguments
11    ///
12    /// * `panel_area` - The area where the button will be rendered
13    /// * `title` - The title text to display
14    ///
15    /// # Returns
16    ///
17    /// A `Line` containing the title span and the button span
18    ///
19    /// # Note
20    ///
21    /// This method updates the button's internal area for click detection
22    pub fn render_with_title(&mut self, panel_area: Rect, title: &str) -> Line<'static> {
23        let (button_span, area) = self.render(panel_area, title);
24        self.area = Some(area);
25        let title_line = Line::from(vec![Span::raw(title.to_string()), button_span]);
26        title_line
27    }
28}