pub struct Theme {}Expand description
Semantic style tokens and widget helpers for a Charm-like ratatui UI.
Fields§
§palette: PaletteSource palette used to build semantic styles.
symbols: SymbolsShared symbols used by helper methods.
text: StyleMain text style.
muted: StyleMuted secondary text style.
accent: StylePrimary accent style.
success: StyleSuccess style.
warning: StyleWarning style.
error: StyleError style.
border: StyleNormal border style.
focused_border: StyleFocused border style.
title: StyleBlock title style.
selected: StyleSelected row/item style.
help_key: StyleHelp key style.
help_desc: StyleHelp description style.
Implementations§
Source§impl Theme
impl Theme
Sourcepub fn new(palette: Palette, symbols: Symbols) -> Self
pub fn new(palette: Palette, symbols: Symbols) -> Self
Builds a theme from a palette and symbol set.
Sourcepub fn block<'a>(&self) -> Block<'a>
pub fn block<'a>(&self) -> Block<'a>
Creates a rounded bordered block using the theme’s default border and title styles.
Sourcepub fn block_with_focus<'a>(&self, focused: bool) -> Block<'a>
pub fn block_with_focus<'a>(&self, focused: bool) -> Block<'a>
Creates a rounded bordered block with focus-aware border styling.
Examples found in repository?
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let theme = BubbleTheme::default();
8 let backend = TestBackend::new(48, 8);
9 let mut terminal = Terminal::new(backend)?;
10
11 terminal.draw(|frame| {
12 let area = frame.area();
13 let inner = area.inner(Margin::new(2, 1));
14
15 frame.render_widget(
16 theme
17 .block_with_focus(true)
18 .title(theme.title("ratatui-bubbletea")),
19 area,
20 );
21
22 frame.render_widget(
23 theme.paragraph(vec![
24 theme.bullet("Plain ratatui loop"),
25 theme.checked("Charm-like defaults"),
26 theme.help_line([("q", "quit"), ("?", "help")]),
27 ]),
28 inner,
29 );
30 })?;
31
32 Ok(())
33}Sourcepub fn titled_block<'a, T>(&self, title: T) -> Block<'a>
pub fn titled_block<'a, T>(&self, title: T) -> Block<'a>
Creates a rounded, titled block using the theme’s default title style.
Sourcepub fn modal_block<'a>(&self) -> Block<'a>
pub fn modal_block<'a>(&self) -> Block<'a>
Creates a modal-style block with the focused/accent border style.
This is intended for the common Clear + centered-popup pattern.
Sourcepub fn titled_modal_block<'a, T>(&self, title: T) -> Block<'a>
pub fn titled_modal_block<'a, T>(&self, title: T) -> Block<'a>
Creates a titled modal-style block with the focused/accent border style.
Sourcepub fn paragraph<'a, T>(&self, text: T) -> Paragraph<'a>
pub fn paragraph<'a, T>(&self, text: T) -> Paragraph<'a>
Creates a paragraph using the theme’s normal text style.
Examples found in repository?
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let theme = BubbleTheme::default();
8 let backend = TestBackend::new(48, 8);
9 let mut terminal = Terminal::new(backend)?;
10
11 terminal.draw(|frame| {
12 let area = frame.area();
13 let inner = area.inner(Margin::new(2, 1));
14
15 frame.render_widget(
16 theme
17 .block_with_focus(true)
18 .title(theme.title("ratatui-bubbletea")),
19 area,
20 );
21
22 frame.render_widget(
23 theme.paragraph(vec![
24 theme.bullet("Plain ratatui loop"),
25 theme.checked("Charm-like defaults"),
26 theme.help_line([("q", "quit"), ("?", "help")]),
27 ]),
28 inner,
29 );
30 })?;
31
32 Ok(())
33}Sourcepub fn paragraph_in_block<'a, T, L>(&self, text: T, title: L) -> Paragraph<'a>
pub fn paragraph_in_block<'a, T, L>(&self, text: T, title: L) -> Paragraph<'a>
Creates a paragraph with a themed block attached.
Sourcepub fn title<'a, T>(&self, content: T) -> Line<'a>
pub fn title<'a, T>(&self, content: T) -> Line<'a>
Creates a title line.
Examples found in repository?
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let theme = BubbleTheme::default();
8 let backend = TestBackend::new(48, 8);
9 let mut terminal = Terminal::new(backend)?;
10
11 terminal.draw(|frame| {
12 let area = frame.area();
13 let inner = area.inner(Margin::new(2, 1));
14
15 frame.render_widget(
16 theme
17 .block_with_focus(true)
18 .title(theme.title("ratatui-bubbletea")),
19 area,
20 );
21
22 frame.render_widget(
23 theme.paragraph(vec![
24 theme.bullet("Plain ratatui loop"),
25 theme.checked("Charm-like defaults"),
26 theme.help_line([("q", "quit"), ("?", "help")]),
27 ]),
28 inner,
29 );
30 })?;
31
32 Ok(())
33}Sourcepub fn bullet<'a, T>(&self, content: T) -> Line<'a>
pub fn bullet<'a, T>(&self, content: T) -> Line<'a>
Creates a line prefixed with the default bullet symbol.
Examples found in repository?
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let theme = BubbleTheme::default();
8 let backend = TestBackend::new(48, 8);
9 let mut terminal = Terminal::new(backend)?;
10
11 terminal.draw(|frame| {
12 let area = frame.area();
13 let inner = area.inner(Margin::new(2, 1));
14
15 frame.render_widget(
16 theme
17 .block_with_focus(true)
18 .title(theme.title("ratatui-bubbletea")),
19 area,
20 );
21
22 frame.render_widget(
23 theme.paragraph(vec![
24 theme.bullet("Plain ratatui loop"),
25 theme.checked("Charm-like defaults"),
26 theme.help_line([("q", "quit"), ("?", "help")]),
27 ]),
28 inner,
29 );
30 })?;
31
32 Ok(())
33}Sourcepub fn checked<'a, T>(&self, content: T) -> Line<'a>
pub fn checked<'a, T>(&self, content: T) -> Line<'a>
Creates a success line prefixed with the default check symbol.
Examples found in repository?
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let theme = BubbleTheme::default();
8 let backend = TestBackend::new(48, 8);
9 let mut terminal = Terminal::new(backend)?;
10
11 terminal.draw(|frame| {
12 let area = frame.area();
13 let inner = area.inner(Margin::new(2, 1));
14
15 frame.render_widget(
16 theme
17 .block_with_focus(true)
18 .title(theme.title("ratatui-bubbletea")),
19 area,
20 );
21
22 frame.render_widget(
23 theme.paragraph(vec![
24 theme.bullet("Plain ratatui loop"),
25 theme.checked("Charm-like defaults"),
26 theme.help_line([("q", "quit"), ("?", "help")]),
27 ]),
28 inner,
29 );
30 })?;
31
32 Ok(())
33}Sourcepub fn crossed<'a, T>(&self, content: T) -> Line<'a>
pub fn crossed<'a, T>(&self, content: T) -> Line<'a>
Creates an error line prefixed with the default cross symbol.
Sourcepub fn help_line<'a, I, K, D>(&self, bindings: I) -> Line<'a>
pub fn help_line<'a, I, K, D>(&self, bindings: I) -> Line<'a>
Creates a compact help line from (key, description) pairs.
Examples found in repository?
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let theme = BubbleTheme::default();
8 let backend = TestBackend::new(48, 8);
9 let mut terminal = Terminal::new(backend)?;
10
11 terminal.draw(|frame| {
12 let area = frame.area();
13 let inner = area.inner(Margin::new(2, 1));
14
15 frame.render_widget(
16 theme
17 .block_with_focus(true)
18 .title(theme.title("ratatui-bubbletea")),
19 area,
20 );
21
22 frame.render_widget(
23 theme.paragraph(vec![
24 theme.bullet("Plain ratatui loop"),
25 theme.checked("Charm-like defaults"),
26 theme.help_line([("q", "quit"), ("?", "help")]),
27 ]),
28 inner,
29 );
30 })?;
31
32 Ok(())
33}Trait Implementations§
impl Copy for Theme
impl Eq for Theme
impl StructuralPartialEq for Theme
Auto Trait Implementations§
impl Freeze for Theme
impl RefUnwindSafe for Theme
impl Send for Theme
impl Sync for Theme
impl Unpin for Theme
impl UnsafeUnpin for Theme
impl UnwindSafe for Theme
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more