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
NPM
npm install @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')
Nuxt 3
import NbButtonsComponents from '@vlalg-nimbus/nb-buttons'
import "@vlalg-nimbus/nb-buttons/dist/style.css";

export default defineNuxtPlugin(context => {
  context.vueApp.use(NbButtonsComponents)
})

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>
Mode 2
<template>
  <nb-button-gradient-border-to-background />
</template>
Mode 3
<template>
  <nb-button-gradient-border-to-background></nb-button-gradient-border-to-background>
</template>

Preview & Playground

Select the component you want to edit/test

Loading Sandbox...

Props

Items with an (*) mean they are required

nameValue typeDefaultDescription
nbId (*)StringSets the id attribute to differentiate from other components
displayString'b'Defines the display type. Accepts ib and b.
tabIndexNumber0Defines the tab index. Set this property to make the button focusable by the keyboard.
hasTabIndexEnterBooleantrueEnables the button to be activated with the Enter key when focused.
hasTabIndexSpaceBooleantrueEnables the button to be activated with the Space key when focused.
ariaLabelString'Alternate Text Button'Defines the aria-label attribute for screen readers.
ariaAttrsObject{}Allows passing custom aria attributes as an object. Keys will automatically receive the aria- prefix. Example: { 'describedby': 'help-id', 'invalid': 'false' }
textColorString'#ffffff'Defines the text color. Accepts Color name and Hex
textHoverColorString'blue'Defines the text color on hover. Accepts Color name and Hex
buttonColorString'linear-gradient(120deg,#fa7faa,#ff9691 25%,#ffb287 50%,transparent 55%,transparent)'Defines the button background gradient. Accepts CSS gradient
buttonHoverColorString'linear-gradient(11deg, #c83852, #b44092 50%, #6a5fc1)'Defines the button background gradient on hover. Accepts CSS gradient
showBorderBooleantrueDefines if the border should be shown.
borderRadiusNumber0.375Defines border-radius.
widthNumber86Defines button width.
paddingXNumber1Defines button padding-left and padding-right.
paddingYNumber0.2Defines button padding-top and padding-button.
disabledBooleanfalseDefines if the button is disabled
fontFamilyString"'Lato', sans-serif"Defines the font-family
fontSizeString'1.6em'Defines the font-size
fontWeightNumber200Defines the font-weight

Events

nameReturn typeDescription
clickednothingFired 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>