1.3.0 • Published 1 year ago

rescript-ink v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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!

:dancers: 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