Expand description
Simple RSX - A lightweight JSX-like library for Rust
This crate provides a simple way to write HTML-like components in Rust using JSX-style syntax. It’s perfect for building user interfaces or generating HTML content with a familiar, component-based approach.
§Quick Start
use simple_rsx::*;
// Create a simple component
let greeting = rsx!(
<div class="greeting">
<h1>Hello, World!</h1>
<p>Welcome to Simple RSX</p>
</div>
);
// Convert to HTML string
println!("{}", greeting); // Outputs the HTML§Features
- JSX-like syntax with the
rsx!macro - Component-based architecture
- Type-safe attributes and children
- Easy conversion to HTML strings
- Support for custom components
§Custom Components
use simple_rsx::*;
#[derive(Default)]
struct ButtonProps {
text: String,
children: Vec<Node>,
}
#[component]
fn Button(props: ButtonProps) -> Node {
rsx!(
<button class="btn">
{props.text}
{props.children}
</button>
)
}Modules§
Macros§
- either
- A procedural macro that transforms a conditional expression into a JSX-like syntax.
- rsx
- A procedural macro that provides JSX-like syntax for creating HTML elements in Rust.
Structs§
- Element
- Represents an HTML element with its tag name, attributes, and children.
Enums§
- Node
- Represents a node in the RSX tree.
Traits§
- Attribute
- A trait for converting values into HTML attribute strings.
- Component
- A trait for creating reusable components.
- Option
Attribute - A trait for handling optional attribute values.
Attribute Macros§
- component
- A procedural macro that transforms a rust function into a component.