A customizable checkbox widget for Ratatui TUI applications.
- ☑️ Simple checkbox with label
- 🎨 Customizable styling for checkbox and label separately
- 🔤 Custom symbols (unicode, emoji, ASCII)
- 📦 Block wrapper - optional
- 📍 Label positioning (right, left, top, bottom) - optional
↔️ Horizontal & vertical alignment - optional- 📏 Width constraints (min/max) - optional
- 📝 Text wrapping for long labels - optional
- ⚡ Zero-cost abstractions
Add this to your Cargo.toml:
[dependencies]
tui-checkbox = "0.2.0"
ratatui = "0.29"Or install with cargo:
cargo add tui-checkboxuse ratatui::style::{Color, Style, Modifier};
use tui_checkbox::Checkbox;
// Basic checkbox
let checkbox = Checkbox::new("Enable feature", true);
// Styled checkbox
let checkbox = Checkbox::new("Enable feature", true)
.style(Style::default().fg(Color::White))
.checkbox_style(Style::default().fg(Color::Green).add_modifier(Modifier::BOLD))
.label_style(Style::default().fg(Color::Gray));
// Custom symbols
let checkbox = Checkbox::new("Task", false)
.checked_symbol("✅ ")
.unchecked_symbol("⬜ ");
// With a block
use ratatui::widgets::Block;
let checkbox = Checkbox::new("Accept terms", false)
.block(Block::bordered().title("Settings"));Control where the label appears relative to the checkbox symbol.
Note: All layout features are optional! The checkbox works perfectly with sensible defaults. Only use these methods when you need to customize the layout.
use tui_checkbox::{Checkbox, LabelPosition};
// Simple checkbox - works great with defaults!
Checkbox::new("Enable feature", true);
// Label on the left (optional customization)
Checkbox::new("Enable feature", true)
.label_position(LabelPosition::Left);
// Label on top (optional customization)
Checkbox::new("Enable feature", false)
.label_position(LabelPosition::Top);
// Label on bottom (optional customization)
Checkbox::new("Enable feature", false)
.label_position(LabelPosition::Bottom);Defaults: Label on the right (standard checkbox style)
Align the checkbox content within its area. Only needed for specific layouts.
use tui_checkbox::{Checkbox, HorizontalAlignment, VerticalAlignment};
// Horizontal alignment (optional)
Checkbox::new("Centered", true)
.horizontal_alignment(HorizontalAlignment::Center);
Checkbox::new("Right", true)
.horizontal_alignment(HorizontalAlignment::Right);
// Vertical alignment (optional)
Checkbox::new("Middle", false)
.vertical_alignment(VerticalAlignment::Center);
Checkbox::new("Bottom", false)
.vertical_alignment(VerticalAlignment::Bottom);Defaults: Left and top aligned
Set minimum and maximum width constraints, and enable text wrapping when needed.
// Minimum width (optional)
Checkbox::new("Small label", true)
.min_width(30);
// Maximum width (optional)
Checkbox::new("This is a very long label that will be constrained", false)
.max_width(25);
// Text wrapping (optional - for long labels)
Checkbox::new("This is a very long label that demonstrates text wrapping", true)
.wrap_label(true)
.max_width(30);Defaults: No width constraints, no wrapping
See all four label positions in action:
cargo run --example checkbox_label_positionThis demonstrates: right, left, top, and bottom label positions.
See horizontal and vertical alignment:
cargo run --example checkbox_alignmentThis demonstrates:
- Horizontal alignment: left, center, right
- Vertical alignment: top, center, bottom
See width constraints and text wrapping:
cargo run --example checkbox_width_wrappingThis demonstrates:
- Minimum and maximum width constraints
- Text wrapping (enabled vs disabled)
- Combined features
Run the included example with two modes:
cargo run --example checkboxNavigate and toggle checkboxes with your keyboard:
- ↑/↓ or k/j - Navigate between checkboxes
- Space - Toggle checkbox state
- Tab - Switch to API Showcase mode
- q or Esc - Quit
The interactive mode demonstrates:
- Basic checkbox with default styling
- Styled checkboxes with colors (Info, Warning, Error)
- Emoji and Unicode symbols (✅, ●, ◆)
- Custom ASCII symbols ([X], [*], [+]/[-], (X)/(O))
Press Tab to switch to the API showcase view, which displays all available features:
- All core API methods (
new(),default(),label(),checked()) - All styling methods (
style(),checkbox_style(),label_style()) - Symbol customization (
checked_symbol(),unchecked_symbol()) - All predefined symbols from the
symbolsmodule - Advanced usage (blocks, Styled trait, method chaining)
The widget supports multiple styling options:
style(): Sets the base style for the entire widgetcheckbox_style(): Sets the style specifically for the checkbox symbollabel_style(): Sets the style specifically for the label text
Styles are applied in order: base style, then specific styles override it.
The widget comes with default Unicode checkbox symbols (☐ and ☑), but you can use any symbols:
// Emoji style
Checkbox::new("Task", true)
.checked_symbol("✅ ")
.unchecked_symbol("⬜ ");
// ASCII style
Checkbox::new("Task", false)
.checked_symbol("[X]")
.unchecked_symbol("[ ]");
// Circle style
Checkbox::new("Task", true)
.checked_symbol("● ")
.unchecked_symbol("○ ");The symbols module provides some common checkbox symbols:
symbols::CHECKED- ☑symbols::UNCHECKED- ☐symbols::CHECKED_X- [X]symbols::UNCHECKED_SPACE- [ ]symbols::CHECKED_ASTERISK- [*]symbols::CHECKED_PLUS- [+]symbols::UNCHECKED_MINUS- [-]symbols::CHECKED_PARENTHESIS_X- (X)symbols::UNCHECKED_PARENTHESIS_O- (O)
Install tools:
just install-tools# Run example
just run
# Run tests
just test
# Format and lint
just fmt
just clippy
# Check all (format, clippy, tests)
just check-all
# Release check (format, clippy, test, build)
just release-check
# Generate demo GIF (requires VHS)
just vhs# Release to GitHub only
just release 0.2.0
# Release to Gitea only (if configured)
just release-gitea 0.2.0
# Release to both GitHub and Gitea
just release-all 0.2.0The release commands automatically:
- Bump version in Cargo.toml
- Update Cargo.lock
- Generate changelog with git-cliff
- Create git commit and tag
- Push to the selected remote(s)
If you have a Gitea instance configured:
# Setup Gitea remote
just setup-gitea [email protected]:username/tui-checkbox.git
# Push to both GitHub and Gitea
just push-all
# Sync Gitea with GitHub
just sync-gitea
# Show configured remotes
just remotesSee all available commands:
just --listMIT License - see LICENSE for details.
Contributions are welcome! Please follow these guidelines:
- Fork the repository on GitHub
- Create a feature branch from
main - Make your changes with clear commit messages
- Submit a pull request to the main repository
All contributions must be made through GitHub pull requests from your fork. Please see CONTRIBUTING.md for detailed guidelines.
This widget was created for the Ratatui ecosystem.
Special thanks to the Ratatui team for creating such an amazing TUI framework.



