Expand description
Cursor component for Bubble Tea-style text inputs.
This component provides a reusable text cursor for inputs, text areas, and other widgets that need a caret. It supports blinking, static, and hidden modes and can be themed via Lip Gloss styles.
The cursor is typically embedded inside another component (for example the
textarea model) and updated by forwarding messages. It can also be used as a
standalone bubbletea_rs::Model for demonstration or tests.
§Example
use bubbletea_widgets::cursor;
use lipgloss_extras::prelude::*;
let mut cur = cursor::new();
cur.style = Style::new().reverse(true); // style when the cursor block is shown
cur.text_style = Style::new(); // style for the character underneath when hidden
let _ = cur.focus(); // start blinking
cur.set_char("x");
let _maybe_cmd = cur.set_mode(cursor::Mode::Blink);
let view = cur.view();
assert!(!view.is_empty());Structs§
- Blink
Msg - Message that signals the cursor should blink.
- Initial
Blink Msg - Message to start the cursor blinking.
- Model
- Model is the Bubble Tea model for this cursor element.
Enums§
- Mode
- Describes the behavior of the cursor.