nb-button-gradient-border-to-background
This is a gradient border to background 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 NbButtonGradientBorderToBackground or nb-button-gradient-border-to-background.
Mode 1
<template>
<NbButtonGradientBorderToBackground />
</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' } |
| textColor | String | '#ffffff' | Defines the text color. Accepts Color name and Hex |
| textHoverColor | String | 'blue' | Defines the text color on hover. Accepts Color name and Hex |
| buttonColor | String | 'linear-gradient(120deg,#fa7faa,#ff9691 25%,#ffb287 50%,transparent 55%,transparent)' | Defines the button background gradient. Accepts CSS gradient |
| buttonHoverColor | String | 'linear-gradient(11deg, #c83852, #b44092 50%, #6a5fc1)' | Defines the button background gradient on hover. Accepts CSS gradient |
| showBorder | Boolean | true | Defines if the border should be shown. |
| borderRadius | Number | 0.375 | Defines border-radius. |
| width | Number | 86 | Defines button width. |
| 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 |
| fontFamily | String | "'Lato', sans-serif" | Defines the font-family |
| fontSize | String | '1.6em' | Defines the font-size |
| fontWeight | Number | 200 | Defines the font-weight |
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>
<NbButtonGradientBorderToBackground
:nb-id="'nb-button-gradient-border-to-background-one'"
:display="'b'"
textColor="#ffffff"
textHoverColor="blue"
buttonColor="linear-gradient(120deg,#fa7faa,#ff9691 25%,#ffb287 50%,transparent 55%,transparent)"
buttonHoverColor="linear-gradient(11deg, #c83852, #b44092 50%, #6a5fc1)"
:showBorder="true"
:borderRadius="0.375"
:tabIndex="0"
:hasTabIndexEnter="true"
:hasTabIndexSpace="true"
ariaLabel="Botão com gradiente de borda para fundo"
@clicked="logEvent()"
>
<template #content>
Default Text
</template>
</NbButtonGradientBorderToBackground>
</template>
<script setup>
defineOptions({
name: 'CompGradientBorderToBackground',
});
const logEvent = () => {
console.log('clicked');
};
</script>
Table of Contents
