Skip to content

Variable: limitOptions ​

ts
const 
limitOptions
: <
TOption
>({
cursor
,
options
,
style
,
output
,
maxItems
,
columnPadding
,
rowPadding
,
}) => string[];

Defined in: node_modules/.pnpm/@clack+prompts@1.9.0/node_modules/@clack/prompts/dist/index.d.mts:592

Trims an option list to what fits the terminal, while keeping the active option (cursor) visible using a Clack style sliding window.

Type Parameters ​

Type Parameter

TOption

Parameters ​

ParameterType

{ cursor, options, style, output, maxItems, columnPadding, rowPadding, }

LimitOptionsParams<TOption>

Returns ​

string[]

The lines to render.

See ​

https://bomb.sh/docs/clack/packages/prompts/#limitoptions

Example ​

ts
import { 
limitOptions
} from "@clack/prompts";
import {
styleText
} from "node:util";
const
options
= ["apple", "banana", "cherry", "date"];
const
lines
=
limitOptions
({
options
,
cursor
: 2,
maxItems
: 8,
style
: (
opt
,
active
) =>
active
?
styleText
("cyan",
opt
) :
styleText
("dim",
opt
),
});

Released under the MIT License