Pastel Quickstart
This quickstart builds off Getting Started and assumes you have a native Reason project set up.
Install Pastel
To install Pastel in your project with esy, run
esy add @reason-native/pastel
This will add @reason-native/pastel
into your package.json
.
In order to use Pastel, you must add it to your build system. With dune, pastel.lib
must be added to the relevant dune
file:
(libraries ... pastel.lib)
Sample Code
Pastel is fundamentally a Reason JSX element that wraps text in ANSI-compatible formatting. You can specify attributes such as bold
, underline
, and color
to format terminal output. Wrap your pastel elements with Pastel.()
to convert it to a string:
let output =
Pastel.(
<Pastel bold=true color=Green>
"Hello "
<Pastel italic=true underline=true> "World" </Pastel>
</Pastel>
);
print_endline(output);
[32m[1mHello [22m[39m[32m[1m[3m[4mWorld[24m[23m[22m[39m