ButtonOptions
The ButtonOptions type defines the configuration for an individual button in ts-better-console. It specifies the label, styling, hover styling, and click handler for a terminal button.
Type Definition
The ButtonOptions type includes the following properties:
label: A string representing the text displayed on the button.style: An optionalStyleOptionsobject that defines the default styling of the button.hoverStyle: An optionalStyleOptionsobject that defines the styling applied when the button is hovered or focused.onClick: A callback function that is invoked when the button is clicked.
type ButtonOptions = {
label: string;
style?: StyleOptions;
hoverStyle?: StyleOptions;
onClick: () => void;
}
Usage
You can use ButtonOptions when creating buttons in the terminal:
import { ButtonGroup } from "ts-better-console";
const buttonGroup = new ButtonGroup([
{
label: "Click Me",
style: { color: "white", backgroundColor: "blue" },
hoverStyle: { color: "white", backgroundColor: "cyan" },
onClick: () => {
// Handle button click
console.log("Button clicked!");
buttonGroup.destroy();
}
}]);
buttonGroup.show();
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!