tui-checkbox
A customizable checkbox widget for Ratatui TUI applications.
🏠 Hosting
This project is hosted on multiple platforms for redundancy:
-
🐙 GitHub - sorinirimies/tui-checkbox
- Primary public repository
- CI/CD with GitHub Actions
- Issue tracking and discussions
-
🍵 Gitea - Self-hosted mirror (optional)
- Full backup and redundancy
- CI/CD with Gitea Actions
- Independent deployment option
Both repositories are kept in sync automatically. See DUAL_HOSTING.md for setup details.
Preview
Features
- ☑️ Simple checkbox with label
- 🎨 Customizable styling for checkbox and label separately
- 🔤 Custom symbols (unicode, emoji, ASCII)
- 📦 Optional block wrapper
- ⚡ Zero-cost abstractions
Installation
Add this to your Cargo.toml:
[]
= "0.2.0"
= "0.29"
Or install with cargo:
Quick Start
use ;
use Checkbox;
// Basic checkbox
let checkbox = new;
// Styled checkbox
let checkbox = new
.style
.checkbox_style
.label_style;
// Custom symbols
let checkbox = new
.checked_symbol
.unchecked_symbol;
// With a block
use Block;
let checkbox = new
.block;
Examples
Run the included example with two modes:
Interactive Mode (Default)
Navigate 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))
API Showcase Mode
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)
Styling
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.
Custom Symbols
The widget comes with default Unicode checkbox symbols (☐ and ☑), but you can use any symbols:
// Emoji style
new
.checked_symbol
.unchecked_symbol;
// ASCII style
new
.checked_symbol
.unchecked_symbol;
// Circle style
new
.checked_symbol
.unchecked_symbol;
Predefined Symbols
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)
Development
Prerequisites
Install tools:
Common Tasks
# Run example
# Run tests
# Format and lint
# Check all (format, clippy, tests)
# Release check (format, clippy, test, build)
# Generate demo GIF (requires VHS)
Release Workflow
# Release to GitHub only
# Release to Gitea only (if configured)
# Release to both GitHub and Gitea
The 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)
Dual Hosting Commands
If you have a Gitea instance configured:
# Setup Gitea remote
# Push to both GitHub and Gitea
# Sync Gitea with GitHub
# Show configured remotes
See DUAL_HOSTING.md for complete dual hosting setup guide.
See all available commands:
License
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Acknowledgments
This widget was created for the Ratatui ecosystem.
Special thanks to the Ratatui team for creating such an amazing TUI framework.