rescript-ink

1.3.0 • Public • Published

ReScript Ink

npm license

ReScript bindings for Ink

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

Features

Core

Core:

  • [x] render
  • [x] ref & measureElement

Components:

  • [x] Box
  • [x] Text
  • [x] Newline
  • [x] Spacer
  • [x] Static
  • [x] Transform

Hooks:

  • [x] useApp
  • [x] useInput
  • [x] useFocus
  • [x] useFocusManager
  • [x] useStdin
  • [x] useStdout
  • [x] 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

Package Sidebar

Install

npm i rescript-ink

Weekly Downloads

1

Version

1.3.0

License

MIT

Unpacked Size

35.5 kB

Total Files

56

Last publish

Collaborators

  • cometkim