MenuOptions
The MenuOptions type defines the configuration options for a menu component in ts-better-console. These options allow you to customize the appearance and behavior of the interactive menu, including selection icons, styling, and the default selected index.
Type Definition
The MenuOptions type includes the following properties:
selectedIcon: An optional string for the icon displayed next to the currently selected menu item.unselectedIcon: An optional string for the icon displayed next to unselected menu items.focusStyle: An optionalStyleOptionsobject defining the styling applied to the focused/selected item.itemStyle: An optionalStyleOptionsobject defining the default styling for all menu items.defaultIndex: An optional number specifying the index of the item that should be selected by default when the menu is first displayed.
type MenuOptions = {
selectedIcon?: string;
unselectedIcon?: string;
focusStyle?: StyleOptions;
itemStyle?: StyleOptions;
defaultIndex?: number;
}
Usage
You can pass MenuOptions when creating a menu to customize its appearance:
import { Menu } from "ts-better-console";
new Menu([{ label: "Apple" },{ label: "Banana" },{ label: "Cherry" },],{).show();selectedIcon: "👉",unselectedIcon: " ",focusStyle: { color: "cyan", styles: ["bold"] },defaultIndex: 0,}
Want to support this project?
If you find ts-better-console useful and want to support its development, consider starring the GitHub repository or buying me a coffee! Your support helps me dedicate more time to improving the library and adding new features.
Want to contribute to this project?
Contributions are welcome! If you're interested in improving the library, fixing bugs, or adding new features, feel free to check out the GitHub repository and submit a pull request. Whether you're a seasoned developer or new to open source, your contributions can make a difference!