{"id":51655005,"url":"https://github.com/allisonhere/ratatui-color-picker","last_synced_at":"2026-07-14T08:31:06.579Z","repository":{"id":362733904,"uuid":"1260441305","full_name":"allisonhere/ratatui-color-picker","owner":"allisonhere","description":"An interactive terminal color picker for ratatui: RGB sliders, HSL field, hex input, keyboard + mouse.","archived":false,"fork":false,"pushed_at":"2026-06-05T16:53:04.000Z","size":219,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-05T18:39:24.489Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allisonhere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-05T13:51:37.000Z","updated_at":"2026-06-05T16:53:08.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/allisonhere/ratatui-color-picker","commit_stats":null,"previous_names":["allisonhere/ratatui-color-picker"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/allisonhere/ratatui-color-picker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisonhere%2Fratatui-color-picker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisonhere%2Fratatui-color-picker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisonhere%2Fratatui-color-picker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisonhere%2Fratatui-color-picker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allisonhere","download_url":"https://codeload.github.com/allisonhere/ratatui-color-picker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allisonhere%2Fratatui-color-picker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35453842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-14T02:00:06.603Z","response_time":114,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-14T08:31:06.457Z","updated_at":"2026-07-14T08:31:06.566Z","avatar_url":"https://github.com/allisonhere.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ratatui-color-picker\n\nAn interactive terminal color picker for [ratatui](https://ratatui.rs).\n\n`ColorEditor` is a self-contained, render-agnostic state machine for editing a single\ncolor. It keeps **RGB**, **HSL**, and **HSV** in sync, manages keyboard focus / tab order,\nsupports inline numeric and hex text editing with validation, and does mouse hit-testing\nagainst a computed layout. You drive it from your event loop and draw it however you like.\n\n\u003e Extracted from a real Zellij theme editor, where it's the daily-driver color picker.\n\n### RGB sliders\n\n![RGB sliders mode](rgb.png)\n\n### HSL field\n\n![HSL field mode](hsl.png)\n\n## Why\n\nThe TUI color-picker space is thin. The handful of existing crates are either pure color\n*conversion* libraries (e.g. [`coolor`](https://crates.io/crates/coolor)) or a basic RGB\ncolor *wheel*. This one is a full editor:\n\n- **Two modes** — three **RGB sliders**, or a 2-D **HSL field + lightness slider**\n- **Hex input** — type `rrggbb` directly\n- **Inline numeric editing** — edit any R/G/B or H/S/L channel as text, with validation\n  and range clamping\n- **Hue preservation** — desaturating toward grey doesn't lose your hue\n- **Keyboard** — full tab order across every control\n- **Mouse** — click-to-focus and drag, via `focus_for_point` hit-testing\n- **Render-agnostic** — the crate owns the model + layout; you own the pixels\n\n## Install\n\n```toml\n[dependencies]\nratatui-color-picker = \"0.1\"\n```\n\n## Usage\n\n```rust\nuse ratatui_color_picker::{ColorEditor, ColorPickerFocus, picker_layout};\n\n// Seed from an existing color (anything Into\u003cRgbColor\u003e: [u8; 3] or RgbColor).\nlet mut editor = ColorEditor::from_color([0x89, 0xb4, 0xfa]);\n\n// --- in your event loop, translate input into editor calls ---\neditor.focus_next(false);          // Tab — move focus across controls\neditor.adjust_focused_numeric(5.0); // ↑ on the focused channel\neditor.start_editing_focused();    // begin typing into the focused text field\n// editor.push_input_char('a'); editor.commit_text_edit();\n\n// --- when drawing, compute the layout for your overlay Rect ---\n// let rects = picker_layout(overlay_rect, editor.mode());\n// ... render using rects + editor state ...\n\n// --- read the result ---\nlet rgb = editor.to_rgb();\nlet style_color: ratatui::style::Color = rgb.into();\nprintln!(\"{}\", editor.hex()); // \"#89b4fa\"\n```\n\n`ColorEditor` exposes everything you need to wire keyboard and mouse input:\n`focus_next`, `move_rgb_slider_focus`, `adjust_focused_numeric`, `adjust_rgb_slider_selection`,\n`toggle_mode`, `nudge_hsl_field`, `update_from_hsl_field`, `update_lightness_from_frac`,\n`start_hex_input` / `start_editing_focused` / `push_input_char` / `pop_input_char` /\n`commit_text_edit` / `cancel_text_edit`, and `focus_for_point` for mouse hit-testing.\n\n### Drawing it\n\nA ready-made `StatefulWidget` draws the whole picker; the state is your `ColorEditor`:\n\n```rust\nuse ratatui_color_picker::{ColorPicker, PickerTheme};\n\n// in your draw closure:\nframe.render_stateful_widget(\n    ColorPicker::new().original(Some(starting_color)), // optional before→after swatch\n    overlay_area,\n    \u0026mut editor,\n);\n```\n\nTheme it by passing a `PickerTheme` to `.theme(...)` — `PickerTheme::default()` matches the\nlook shipped here. Prefer to draw it yourself? The same `picker_layout`, `split_three`,\n`hsv_field_cell`, `contrast_text`, `srgb_f32`, and `normalize_hue` helpers are public.\n\n### Demo\n\nClone the repo and run the bundled example:\n\n```sh\ngit clone https://github.com/allisonhere/ratatui-color-picker\ncd ratatui-color-picker\ncargo run --example demo\n```\n\nTab/Shift-Tab move focus, `M` toggles RGB/HSL, arrows nudge (in the HSL field ←→ change hue\nand ↑↓ change saturation). Tab to a text field (HEX / R,G,B / H,S,L) and press **Enter** to edit\nit — type a value, **Enter** commits, **Esc** cancels. `#` copies the current hex to the\nclipboard, `q` quits (and prints the picked color). **Mouse** works too — click a control to\nfocus it, and click/drag the RGB sliders, the HSL field, or the lightness slider to set a value.\n\n## Status\n\n`0.1` ships the color model, layout, hit-testing, **and a themable `StatefulWidget`**, with\nfull keyboard **and** mouse support demonstrated in `examples/demo.rs`. Contributions welcome.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallisonhere%2Fratatui-color-picker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallisonhere%2Fratatui-color-picker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallisonhere%2Fratatui-color-picker/lists"}