html_view
The library component of the html_view suite of crates.
Allows the user to open up the viewer from within their application.
Quick Start
Render inline HTML with a single call:
use html_view;
Core Features
- Minimal, single-function API
- Supports inline HTML, local files, application directories, and URLs
- Blocking or non-blocking execution modes
- Secure defaults with explicit opt-in for remote content
- Cross-platform native rendering
- Runtime configuration for window behaviour and lifecycle
Installation
At runtime, html_view requires the viewer application binary.
Install it once:
This installs the viewer into ~/.cargo/bin.
Optional: Command-Line Tool
If you want to use the viewer without writing Rust code:
Usage Patterns
Inline HTML
show?;
Configurable Window
use ViewerOptions;
let mut options = inline_html;
options.window.width = Some;
options.window.height = Some;
options.window.title = Some;
open?;
Non-blocking Execution
use ;
let mut options = inline_html;
options.wait = NonBlocking;
match open?
Files, Directories, and URLs
local_file;
app_dir;
remote_url;
Remote URLs require explicit permission, see Security below.
Time-Limited Display
let mut options = inline_html;
options.environment.timeout_seconds = Some;
open?;
Security
By default:
- Remote content is disabled
- External navigation is blocked
- Developer tools are disabled
- Only provided content is rendered
To enable remote access:
let mut options = inline_html;
options.behaviour.allow_remote_content = true;
options.behaviour.allow_external_navigation = true;
options.behaviour.allowed_domains = Some;
This design prevents accidental network access or data leakage.
License
MIT
Contributing
Contributions are welcome. See CONTRIBUTING.md.
Acknowledgements
Built using Tauri 2.0.