Skip to content

cometkim/rescript-ink

Repository files navigation

ReScript Ink

npm license

ReScript bindings for Ink

Let's build interactive & sound CLI with React and ReScript!

Features

Core

Core:

  • render
  • ref & measureElement

Components:

  • Box
  • Text
  • Newline
  • Spacer
  • Static
  • Transform

Hooks:

  • useApp
  • useInput
  • useFocus
  • useFocusManager
  • useStdin
  • useStdout
  • useStderr

Do you find any missing APIs? Let me know!

👯 Community components bindings

Requirements

  • Ink v3.0.0 or higher
  • ReScript v9.1.0 or higher

Install

yarn add rescript-ink @rescript/react \
  # You can install additional community bindings \
  @reason-ink/ink-big-text

Add it to your bsconfig.json

  "bs-dependencies": [
+   "rescript-ink",
+   "@rescript/react",
+   "@reason-ink/ink-big-text
  ]

Example

open Ink;

// Community bindings have `InkCommunity_` prefix.
module BigText = InkCommunity_BigText;

module App = {
  @react.component
  let make = () => {
    <Box display=#flex justifyContent=#center>
      <BigText text="Hello, Reason-Ink!"/>
    </Box>
  };
};

let {waitUntilExit} = render(<App />, ~exitOnCtrlC=true, ());
waitUntilExit()->ignore;

See more in examples

Contributing

Any feedbacks & contributions are welcome!

See more details in CONTRIBUTING

License

MIT