ink-task-list
Version:
Render a Task list in Ink
145 lines (103 loc) • 3.14 kB
Markdown
Task list components for [Ink](https://github.com/vadimdemedes/ink)
<p align="center">
<img width="400" src=".github/task-list.gif">
</p>
<sub>Support this project by ⭐️ starring and sharing it. [Follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️</sub>
```sh
npm i ink-task-list
```
```tsx
import React from 'react';
import { render } from 'ink';
import { TaskList, Task } from 'ink-task-list';
import spinners from 'cli-spinners';
render(
<TaskList>
{/* Pending state */}
<Task
label="Pending"
state="pending"
/>
{/* Loading state */}
<Task
label="Loading"
state="loading"
spinner={spinners.dots}
/>
{/* Success state */}
<Task
label="Success"
state="success"
/>
{/* Warning state */}
<Task
label="Warning"
state="warning"
/>
{/* Error state */}
<Task
label="Error"
state="error"
/>
{/* Item with children */}
<Task
label="Item with children"
isExpanded
>
<Task
label="Loading"
state="loading"
spinner={spinners.dots}
/>
</Task>
</TaskList>,
);
```
Optional wrapper to contain a list of `Tasks`.
Basically just a `<Box flexDirection="column">`; only for styling and semantic purposes.
Type: `ReactNode | ReactNode[]`
Required
Pass in list of Tasks
Represents each task.
Type: `string`
Required
Type: `'pending'|'loading'|'success'|'warning'|'error'`
Default: `pending`
<img src=".github/states.gif" width="216">
Type: `string`
Status of the task to show on the right of the `label`
<img src=".github/states-w-status.gif" width="216">
Type: `string`
Single-line output prefixed by `→` to show below the `label`
<img src=".github/states-w-output.gif" width="216">
Type:
```ts
type Spinner = {
interval: number
frames: string[]
}
```
Required if state is `loading`
Spinner data used for loading state. Pass in a spinner from [cli-spinners](https://github.com/sindresorhus/cli-spinners) for convenience.
Type: `boolean`
Default: `false`
Whether or not to show the children.
Type: `ReactNode | ReactNode[]`
Pass in one or more `<Task>` components
<img src=".github/nested.gif" width="216">
The component UI was inspired [listr](https://github.com/SamVerschueren/listr) and [listr2](https://github.com/cenk1cenk2/listr2) ❤️