Crates.io | hojicha-pearls |
lib.rs | hojicha-pearls |
version | 0.2.1 |
created_at | 2025-08-11 19:17:38.888152+00 |
updated_at | 2025-08-18 03:03:26.95369+00 |
description | UI components and styling for Hojicha TUI framework |
homepage | https://jgok76.gitea.cloud/femtomc/hojicha |
repository | https://jgok76.gitea.cloud/femtomc/hojicha |
max_upload_size | |
id | 1790705 |
size | 612,721 |
Pre-built UI components and styling system for the Hojicha TUI framework.
This crate provides a rich collection of ready-to-use UI components:
TextInput
, Textarea
List
, Table
, ProgressBar
, Spinner
Tabs
, Paginator
, Modal
use hojicha_pearls::components::{TextInput, List, Button};
use hojicha_pearls::style::Theme;
use hojicha_core::{Model, Cmd, Event};
struct MyApp {
input: TextInput,
list: List<String>,
theme: Theme,
}
impl Model for MyApp {
type Message = MyMessage;
fn view(&self, frame: &mut Frame, area: Rect) {
// Use the pre-built components
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Length(3), Constraint::Min(0)])
.split(area);
self.input.render(frame, chunks[0], &self.theme.color_profile);
self.list.render(frame, chunks[1], &self.theme.color_profile);
}
fn update(&mut self, event: Event<Self::Message>) -> Cmd<Self::Message> {
// Components handle their own events
if self.input.handle_event(event.clone()) {
return Cmd::none();
}
if self.list.handle_event(event.clone()) {
return Cmd::none();
}
// Handle other events...
Cmd::none()
}
}
The pearls crate includes a comprehensive theming system with support for margin backgrounds:
use hojicha_pearls::style::{Theme, ColorProfile, Style};
// Use built-in themes
let theme = Theme::default();
let dark_theme = Theme::dark();
// Or create custom themes
let custom_theme = Theme::builder()
.primary(Color::Cyan)
.secondary(Color::Magenta)
.build();
// Apply margin background colors (Lipgloss-style)
let styled = Style::new()
.background(Color::Blue)
.margin_background(Color::DarkGray)
.margin(2)
.build();
For full documentation and more examples, see the main Hojicha documentation.
GPL-3.0 - See LICENSE file for details