Reason Native
  • Docs
  • Help
  • GitHub

›Pastel

Overview

  • Introduction
  • Native Basics
  • Getting Started

Rely

  • Introduction
  • Quickstart
  • Guides

    • Setup and Teardown
    • Mock Functions

    API Reference

    • Basic API
    • Expect
  • Advanced

Console

  • Introduction
  • Quickstart
  • API

Pastel

  • Introduction
  • Quickstart
  • API
  • Console

Refmterr

  • Introduction
  • Quickstart

File Context Printer

  • Introduction
  • Quickstart
  • API

Pastel API

Prefer reading code? Check out Pastel.rei

All text formatting is accomplished through the <Pastel [props] /> tag.

Available Props

color=Color

The color prop specifies the color of the contained text. It can be any of the 16 4-bit ANSI colors:

color =
  | Black
  | Red
  | Green
  | Yellow
  | Blue
  | Magenta
  | Cyan
  | White
  | BlackBright
  | RedBright
  | GreenBright
  | YellowBright
  | BlueBright
  | MagentaBright
  | CyanBright
  | WhiteBright;

Example:

print_endline(
  Pastel.(
    <Pastel color=Blue> "Hello World" </Pastel>
  )
);
Hello World

backgroundColor=Color

The backgroundColor prop specifies the color of the contained text. It can be any of the 16 4-bit ANSI colors:

backgroundColor =
  | Black
  | Red
  | Green
  | Yellow
  | Blue
  | Magenta
  | Cyan
  | White
  | BlackBright
  | RedBright
  | GreenBright
  | YellowBright
  | BlueBright
  | MagentaBright
  | CyanBright
  | WhiteBright;

Example:

print_endline(
  Pastel.(
    <Pastel backgroundColor=Blue> "Hello World" </Pastel>
  )
);
Hello World

bold=Boolean

The bold prop specifies if Pastel should bold the text:

bold =
  | true
  | false;

Example:

print_endline(
  "Hello " ++
  Pastel.(
    <Pastel bold=true> "World" </Pastel>
  )
);
Hello World

dim=Boolean

The dim prop specifies if Pastel should dim the text:

dim =
  | true
  | false;

Example:

print_endline(
  "Hello " ++
  Pastel.(
    <Pastel dim=true> "World" </Pastel>
  )
);
Hello World

italic=Boolean

The italic prop specifies if Pastel should italicize the text:

italic =
  | true
  | false;

Example:

print_endline(
  "Hello " ++
  Pastel.(
    <Pastel italic=true> "World" </Pastel>
  )
);
Hello World

underline=Boolean

The underline prop specifies if Pastel should underline the text:

underline =
  | true
  | false;

Example:

print_endline(
  "Hello " ++
  Pastel.(
    <Pastel underline=true> "World" </Pastel>
  )
);
Hello World

inverse=Boolean

The inverse prop specifies if Pastel should invert the text:

inverse =
  | true
  | false;

Example:

print_endline(
  "Hello " ++
  Pastel.(
    <Pastel inverse=true> "World" </Pastel>
  )
);
Hello World

hidden=Boolean

The hidden prop specifies if Pastel should hide the text:

hidden =
  | true
  | false;

Example:

print_endline(
  "Hello " ++
  Pastel.(
    <Pastel hidden=true> "World" </Pastel>
  )
);
Hello World

strikethrough=Boolean

The strikethrough prop specifies if Pastel should strike-through the text:

strikethrough =
  | true
  | false;

Example:

print_endline(
  "Hello " ++
  Pastel.(
    <Pastel strikethrough=true> "World" </Pastel>
  )
);
Hello World

Modes

type mode =
  /* uses ANSI escape sequences to achieve lovely terminal coloring */
  | Terminal
  /* Useful for snapshots
  ex: <Pastel color=Red>"My text"</Pastel> => <red>My text</red> */
  | HumanReadable
  /* no coloring */
  | Disabled
/* returns the current mode */
let getMode: unit => mode;
/* sets the current mode (use with caution, prefer useMode) */
let setMode: mode => unit;
/* returns the default inferred mode */
let defaultMode: mode;
/* uses the specified mode for the duration of the passed in function
and then restores the previous mode after execution has completed */
let useMode: (mode, unit => 'a) => 'a;
← QuickstartConsole →
  • Available Props
    • color=Color
    • backgroundColor=Color
    • bold=Boolean
    • dim=Boolean
    • italic=Boolean
    • underline=Boolean
    • inverse=Boolean
    • hidden=Boolean
    • strikethrough=Boolean
  • Modes
Reason Native
Projects
RelyConsolePastelRefmterrFile Context Printer
More
GitHubStar
Facebook Open Source
Copyright © 2021 Facebook Inc.