Expand description
§charmed-wasm
Terminal UI components for the web, compiled to WebAssembly.
This crate provides WebAssembly bindings for the charmed_rust library,
allowing you to use lipgloss styling in web applications.
§Role in charmed_rust
charmed-wasm is the web-facing bridge for the ecosystem:
- lipgloss is re-exported with WASM-friendly APIs.
- It enables sharing the same styling model between terminal and web UI.
§Quick Start (JavaScript)
import init, { newStyle, joinVertical, Position } from 'charmed-wasm';
async function main() {
await init();
const style = newStyle()
.foreground("#ff00ff")
.background("#1a1a1a")
.bold()
.padding(1, 2, 1, 2);
const rendered = style.render("Hello, World!");
document.body.innerHTML = `<pre>${rendered}</pre>`;
}
main();§Available APIs
§Styling (from lipgloss)
newStyle()- Create a new style builderJsStyle- Chainable style configurationJsColor- Color utilities
§Layout
joinHorizontal(position, items)- Join strings horizontallyjoinVertical(position, items)- Join strings verticallyplace(width, height, hPos, vPos, content)- Place content in a container
§Utilities
stringWidth(s)- Get visible width of a stringstringHeight(s)- Get height (line count) of a stringborderPresets()- Get available border preset names
Structs§
Functions§
- border_
presets - Available border preset names.
- init
- Initialize the lipgloss WASM module.
- is_
ready - Check if the module is properly initialized.
- join_
horizontal - Join multiple strings horizontally.
- join_
vertical - Join multiple strings vertically.
- new_
style - Create a new style builder.
- place
- Place content at a position within a container.
- string_
height - Get the height (number of lines) of a string.
- string_
width - Get the visible width of a string (excluding escape codes).
- version
- Module version information.