3 releases
Uses new Rust 2024
0.1.3 | Apr 7, 2025 |
---|---|
0.1.1 | Feb 28, 2025 |
0.1.0 | Feb 28, 2025 |
#242 in Command-line interface
129 downloads per month
89KB
2.5K
SLoC
tui-gradient-block
an extension to ratatui's block widget using colorgrad
Note:
- Complex gradients may have a brief delay in rendering (no more than 100 ms)
- Heavily relies on my other widget called tui-rule (https://crates.io/crates/tui-rule)
- A single block is 4 instances of the rule widget (still renders with minimal delay)
- Code before 0.1.3 will be COMPLETELY outdated
- Updating is highly recommended
Features
- customizable gradients that can be applied to
- fill text
- borders
- titles
- fully customizable borders
- fill text
- padding
- margin
- pre-defined border styles
- gradient themes
- 14 variations for each theme
fn render_gradient_block(frame: &mut Frame) {
let block = GradientBlock::new()
.left_gradient(solid((48, 174, 209)))
.bottom_gradient(solid((48, 174, 209)))
.top_gradient(Box::new(
GradientBuilder::new()
.colors(&[
Color::from_rgba8(48, 174, 209, 1),
Color::from_rgba8(225, 22, 247, 1),
])
.build::<colorgrad::LinearGradient>()
.unwrap(),
))
.right_gradient(Box::new(
GradientBuilder::new()
.colors(&[
Color::from_rgba8(225, 22, 247, 1),
Color::from_rgba8(48, 174, 209, 1),
])
.build::<colorgrad::LinearGradient>()
.unwrap(),
))
.title_top(Line::from(generate_gradient_text!(
"Top title",
GradientBuilder::new().colors(&[
Color::from_rgba8(14, 67, 240),
Color::from_rgba8(90, 34, 128)
]).build::<colorgrad::LinearGradient>()
.unwrap()
)).centered());
frame.render_widget(block, frame.area());
}
with multiple titles and border gradients
multiple pre-defined misc types
pre-defined gradient themes
Some of the gradients are from colormagic
Dependencies
~7–17MB
~243K SLoC