Skip to content

Commit

Permalink
fix: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
joshka committed Jan 13, 2024
1 parent 08e0eb0 commit 4dd48dd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This is an experimental playground for us to explore macros that would be useful
- Constraint-based Layouts: Easily define layout constraints such as fixed, percentage, minimum, and
maximum sizes, as well as ratios.
- Directional Layouts: Specify layouts as either horizontal or vertical with simple macro commands.
- Raw and Styled span format macros.

## Getting Started

Expand All @@ -33,6 +34,8 @@ use ratatui_macros::{
constraints,
horizontal,
vertical,
raw,
styled,
};
```

Expand Down Expand Up @@ -112,6 +115,23 @@ assert_eq!(left.width, 3);
assert_eq!(right.width, 3);
```

## Spans

The `raw!` and `styled!` macros create raw and styled `Span`s respectively. They each take a format
string and arguments. `styled!` accepts as the first paramter any value that can be converted to a
`Style`.

```rust
use ratatui::prelude::*
use ratatui_macros::{styled, raw};

let name = "world!";
let raw_greeting = raw!("hello {name}");
let styled_greeting = styled!(Style::new().green(), "hello {name}");
let styled_greeting = styled!(Color::Green, "hello {name}");
let styled_greeting = styled!(Modifier::BOLD, "hello {name}");
```

## Contributing

Contributions to `ratatui-macros` are welcome! Whether it's submitting a bug report, a feature
Expand Down

0 comments on commit 4dd48dd

Please sign in to comment.