1.1.0 • Published 5 months ago

@todovue/tvbutton v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

TODOvue Button

TvButton is a custom button component for web applications.

npm Netlify Status npm npm GitHub GitHub Release Date

Table of Contents

Installation

Install with npm or yarn

npm install @todovue/tvbutton
yarn add @todovue/tvbutton

Import the component:

import { TvButton } from "@todovue/tvbutton";

You can also register it globally in main.js:

import { createApp } from "vue";
import App from "./App.vue";
import TvButton from "@todovue/tvbutton";

const app = createApp(App);
app.component("TvButton", TvButton);
app.mount("#app");

Usage

<script setup>
import TvButton from "@todovue/tvbutton"; // Only if not imported in main.js
    
const handleClick = () => {
  console.log("Clicked!");
};
</script>

<template>
  <tv-button @click-button="handleClick">
    Click me
  </tv-button>
</template>

Props

NameTypeDefaultDescription
typeStringbuttonDefines the button type: "button" or "icon" (icon-only button).
customStyleObject{}Custom styles for the button (e.g., { backgroundColor: "#000", color: "#fff" }).
isOutlined or outlinedBooleanfalseIf true, the button will be outlined instead of filled.
isSmall or smallBooleanfalseIf true, the button will be small.
isLarge or largeBooleanfalseIf true, the button will be large.
isSuccess or successBooleanfalseIf true, the button will be styled as a success button.
isInfo or infoBooleanfalseIf true, the button will be styled as an info button.
isWarning or warningBooleanfalseIf true, the button will be styled as a warning button.
isError or errorBooleanfalseIf true, the button will be styled as an error button.
isDisabled or disabledBooleanfalseIf true, the button will be disabled.
isText or textBooleanfalseIf true, the button will be styled as a text button.
iconStringnullThe name of the icon to be displayed inside the button.
iconPositionStringrightThe position of the icon (left or right).
buttonTextString''The text inside the button (alternative to using slot).
ariaLabelString''The aria-label attribute for the button.

🔹 Icons

You can use the following icons (icon="account"):

  • account
  • alert
  • arrow-down
  • arrow-left
  • arrow-right
  • arrow-up
  • cancel
  • clone
  • dark
  • download
  • edit
  • favorite
  • help
  • light
  • menu
  • minus
  • plus
  • remove
  • search
  • settings
  • share
  • star
  • update

Events

NameDescription
click-buttonEmitted when the button is clicked. You can use it to call a function, etc.
clickEmitted when the button is clicked. You can use it to call a function, etc.

Customize

You can customize the button style using customStyle. You can include backgroundColor and color.

<script setup>
import TvButton from "@todovue/tvbutton";

const customStyle = {
  backgroundColor: "#0f2e5b",
  color: "#fff",
};
</script>

<template>
  <tv-button :customStyle="customStyle">
    Custom Button
  </tv-button>
</template>

🔥 Icon-Only Button (type="icon")

If you want a button with only an icon, use type="icon". The button will automatically adjust its size.

<tv-button icon="trash" type="icon" />
<tv-button icon="check" type="icon" iconColor="green" />
<tv-button icon="info" type="icon" iconColor="blue" />

Development

Clone the repository and install the dependencies:

git clone https://github.com/TODOvue/todovue-button.git
cd todovue-button
yarn install

🔹 Run the demo

yarn demo

🔹 Run tests

yarn test:unit

🔹 Run the linter

yarn lint

🔹 Build the project (Not required for PRs)

yarn build

License

MIT

1.1.0

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago