Text view
Renders Markdown or plain text: headings, emphasis, code, quotes, lists, rules and tables, all selectable.
Markdown
ui.add(TextView::markdown(DOCUMENT));
Lists
ui.add(TextView::markdown(LISTS));
Code
ui.add(TextView::markdown(CODE));
Quotes and rules
ui.add(TextView::markdown(QUOTE));
Table
ui.add(TextView::markdown(TABLE));
Handling links
let view = TextView::markdown(
"Links open in the app: [one](https://example.com/one), <https://example.com/two>.",
)
.open_links(false)
.show(ui);
if let Some(url) = view.clicked_link {
state.clicked = Some(url);
}
Plain text
ui.add(TextView::plain(
"Plain text keeps *asterisks* and line breaks\nas they are.",
));
ui.add(TextView::markdown("Not selectable.").selectable(false));
The story above is gallery/src/stories/text_view.rs, running in your browser. Every snippet on this page is cut from it.