pub fn text_html(component: &Text) -> String
Expand description
Renders a Text
component into an HTML string with applied styles.
This function takes a Text
component, extracts its properties (such as
foreground color, background color, font size, weight, and optional link),
and generates an HTML tag with the appropriate CSS styles.
§Arguments
component
- A reference to aText
component that contains the content, colors, font properties, and optionally a link.
§Returns
A string representing the HTML tag for the component with the correct styles.
§Example
let text_component = Text::new()
.content("Hello, World!")
.foreground_color((255, 0, 0, 1))
.background_color((0, 0, 0, 0))
.size(16);
let html = text_html(&text_component);
assert_eq!(html, r#"<div style="color: rgba(255, 0, 0, 1); background-color: rgba(0, 0, 0, 0); font-size: 16px; font-family: 'CustomFont', Arial;">Hello, World!</div>"#);