Skip to content

List & Tree

import { list } from "@arshad-shah/clif";
// Unordered (default)
console.log(list(["Apple", "Banana", "Cherry"]));
// ● Apple
// ● Banana
// ● Cherry
// Ordered
console.log(list(["First", "Second", "Third"], { ordered: true }));
// 1. First
// 2. Second
// 3. Third
// Custom marker + indent
list(["Item"], { marker: "", indent: 4 });
OptionTypeDefaultDescription
markerstringBullet glyph (ignored when ordered is true)
markerColorFormattercyanColor applied to the marker / ordinal
indentnumber0Leading spaces before each item
orderedbooleanfalseRender 1., 2., … instead of the bullet marker
import { tree } from "@arshad-shah/clif";
console.log(
tree({
label: "src",
children: [
{
label: "core",
children: [{ label: "colors.ts" }, { label: "args.ts" }],
},
{ label: "output", children: [{ label: "components.ts" }] },
{ label: "index.ts" },
],
}),
);
// src
// ├── core
// │ ├── colors.ts
// │ └── args.ts
// ├── output
// │ └── components.ts
// └── index.ts