pub struct Style {
pub fg: Option<Color>,
pub bg: Option<Color>,
pub bold: bool,
pub italic: bool,
pub underline: bool,
pub dim: bool,
pub strikethrough: bool,
}Expand description
Text styling: foreground/background colors and attributes (bold, italic, underline, dim, strikethrough).
Style is a value type (Copy + Default) used throughout the rendering pipeline. The default style has no colors and no attributes — terminal defaults apply.
§Construction
use tui::{Style, Color};
// Foreground only
let s = Style::fg(Color::Red);
// Builder chain
let s = Style::fg(Color::Cyan).bg_color(Color::DarkBlue).bold().italic();
// Start from default
let s = Style::default().bold().underline();§Merging
merge overlays one style on top of another. Option fields (colors) prefer the overlay when Some; boolean attributes are OR’d:
use tui::{Style, Color};
let base = Style::fg(Color::White).bold();
let overlay = Style::fg(Color::Red); // no bold
let merged = base.merge(overlay);
// merged: fg=Red, bold=trueThis is used internally when composing Span styles but is also useful for building theme-derived styles.
§Fields
All fields are public for direct access:
fg/bg—Option<Color>.Nonemeans “inherit terminal default”.bold/italic/underline/dim/strikethrough— boolean attributes.
Fields§
§fg: Option<Color>§bg: Option<Color>§bold: bool§italic: bool§underline: bool§dim: bool§strikethrough: boolImplementations§
Source§impl Style
impl Style
pub fn fg(color: Color) -> Self
pub fn color(self, color: Color) -> Self
pub fn bg_color(self, color: Color) -> Self
pub fn bold(self) -> Self
pub fn italic(self) -> Self
pub fn underline(self) -> Self
pub fn dim(self) -> Self
pub fn strikethrough(self) -> Self
Trait Implementations§
impl Copy for Style
impl Eq for Style
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnsafeUnpin for Style
impl UnwindSafe for Style
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
Mutably borrows from an owned value. Read more
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§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
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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