nb-button-mechanical
This is a mechanical button component for Vue.js 3+.
Loading component...
Installation
Yarn
yarn add @vlalg-nimbus/nb-buttons
Usage
Vue 3
import { createApp } from 'vue'
import App from './App.vue'
import NbButtonsComponents from '@vlalg-nimbus/nb-buttons'
import "@vlalg-nimbus/nb-buttons/dist/style.css";
const app = createApp(App)
app.use(NbButtonsComponents)
app.mount('#app')
To use, simply call the component, in this case it will be NbButtonMechanical or nb-button-mechanical.
Mode 1
<template>
<NbButtonMechanical />
</template>
Preview & Playground
Select the component you want to edit/test
Loading Sandbox...
Props
Items with an (*) mean they are required
| name | Value type | Default | Description |
|---|---|---|---|
| nbId (*) | String | Sets the id attribute to differentiate from other components | |
| display | String | 'b' | Defines the display type. Accepts ib and b. |
| tabIndex | Number | 0 | Defines the tab index. Set this property to make the button focusable by the keyboard. |
| hasTabIndexEnter | Boolean | true | Enables the button to be activated with the Enter key when focused. |
| hasTabIndexSpace | Boolean | true | Enables the button to be activated with the Space key when focused. |
| ariaLabel | String | 'Alternate Text Button' | Defines the aria-label attribute for screen readers. |
| ariaAttrs | Object | {} | Allows passing custom aria attributes as an object. Keys will automatically receive the aria- prefix. Example: { 'describedby': 'help-id', 'invalid': 'false' } |
| theme | String | 'light' | Defines the theme. Accepts dark and light. When theme is set, uses theme-specific color props. |
| paddingX | Number | 1 | Defines button padding-left and padding-right. |
| paddingY | Number | 0.2 | Defines button padding-top and padding-button. |
| disabled | Boolean | false | Defines if the button is disabled |
| borderRadius | Number | 0.375 | Defines border-radius. |
| animationSlow | Boolean | false | Defines if the animation when hovering the button should be slow or not |
| fontFamily | String | "'Lato', sans-serif" | Defines the font-family |
| fontSize | String | '1.6em' | Defines the font-size |
| fontWeight | Number | 400 | Defines the font-weight |
| lightTextColor | String | '#333333' | Defines the text color for light theme. Accepts Color name and Hex |
| lightButtonColor | String | '#f5f5f5' | Defines the button color (background) for light theme. Accepts Color name and Hex |
| lightContainerColor | String | '#e0e0e0' | Defines the container color (border) for light theme. Accepts Color name and Hex. The container is where the button is allocated, if for example the background of the parent (container) where the button is located is blue, the value set in this property must be blue for the button border to work. |
| lightDisabledBgColor | String | '#dfdfd9' | Defines the disabled background color for light theme. Accepts Color name and Hex |
| darkTextColor | String | '#e0e0e0' | Defines the text color for dark theme. Accepts Color name and Hex |
| darkButtonColor | String | '#2d2d2d' | Defines the button color (background) for dark theme. Accepts Color name and Hex |
| darkContainerColor | String | '#3d3d3d' | Defines the container color (border) for dark theme. Accepts Color name and Hex. The container is where the button is allocated, if for example the background of the parent (container) where the button is located is blue, the value set in this property must be blue for the button border to work. |
| darkDisabledBgColor | String | 'rgba(40, 42, 54, 1)' | Defines the disabled background color for dark theme. Accepts Color name and Hex |
Events
| name | Return type | Description |
|---|---|---|
| clicked | nothing | Fired when the button is clicked, returns nothing. |
Slot
The component has a slot called content where the content that will be manipulated must be passed. It has a default text (Default Text) in case the content does not pass through the slot.
<template>
<NbButtonMechanical
:nb-id="'nb-button-mechanical-one'"
:display="'b'"
theme="light"
>
<template #content>
Default Text
</template>
</NbButtonMechanical>
</template>
Example
Light Theme (default)
<template>
<NbButtonMechanical
nb-id="nb-button-mechanical-light"
display="b"
theme="light"
light-text-color="#1e40af"
light-button-color="#93c5fd"
light-container-color="#60a5fa"
:padding-x="1"
:padding-y="0.2"
:border-radius="0.375"
@clicked="logEvent()"
>
<template #content>Default Text</template>
</NbButtonMechanical>
</template>
<script setup>
defineOptions({
name: 'CompMechanical',
});
const logEvent = () => {
console.log('clicked');
};
</script>
Dark Theme
<template>
<NbButtonMechanical
nb-id="nb-button-mechanical-dark"
display="b"
theme="dark"
dark-text-color="#a78bfa"
dark-button-color="#8b5cf6"
dark-container-color="#7c3aed"
:padding-x="1"
:padding-y="0.2"
:border-radius="0.375"
@clicked="logEvent()"
>
<template #content>Default Text</template>
</NbButtonMechanical>
</template>
<script setup>
defineOptions({
name: 'CompMechanicalDark',
});
const logEvent = () => {
console.log('clicked');
};
</script>
