Function selection_highlight_rect

Source
pub fn selection_highlight_rect(width: Px, height: Px, color: Color)
Expand description

Draws a rectangular highlight, typically used to indicate selected text regions in a text editor.

This component renders a single contiguous rectangle with sharp corners and no shadow, suitable for visually marking selected areas. To highlight selections spanning multiple lines or with complex shapes, use multiple selection_highlight_rect components, each representing a segment of the selection.

§Parameters

  • width: The width of the highlight rectangle, in physical pixels (Px).
  • height: The height of the highlight rectangle, in physical pixels (Px).
  • color: The fill color of the rectangle, including alpha for transparency (Color).

§Example

use tessera_ui::{Color, Px};
use tessera_ui_basic_components::selection_highlight_rect::selection_highlight_rect;

// Renders a selection highlight rectangle with a width of 100px, a height of 20px,
// and a semi-transparent blue color.
selection_highlight_rect(
    Px(100),
    Px(20),
    Color::new(0.2, 0.4, 1.0, 0.3),
);