nb-input

This is an input component for Vue.js 3+.

Loading component...

Installation

Yarn
yarn add @vlalg-nimbus/nb-inputs
NPM
npm install @vlalg-nimbus/nb-inputs

Usage

Vue 3
import { createApp } from 'vue'
import App from './App.vue'

import NbInputComponents from '@vlalg-nimbus/nb-inputs'
import "@vlalg-nimbus/nb-inputs/dist/style.css";

const app = createApp(App)
app.use(NbInputComponents)
app.mount('#app')
Nuxt 3
import NbInputComponents from '@vlalg-nimbus/nb-inputs'
import "@vlalg-nimbus/nb-inputs/dist/style.css";

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

To use, simply call the component, in this case it will be NbInput or nb-input.

Mode 1
<template>
  <NbInput />
</template>
Mode 2
<template>
  <nb-input />
</template>
Mode 3
<template>
  <nb-input></nb-input>
</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
inputName (*)StringSets the name attribute for the input element
displayString'b'Defines the display type. Accepts ib and b.
tabIndexNumber0Defines the tab index. Set this property to make the input focusable by the keyboard.
hasTabIndexEnterBooleantrueEnables the input to be activated with the Enter 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
caretColorString''Defines the caret (cursor) color. Accepts Color name and Hex. If empty, uses default browser color.
selectionBgColorString''Defines the background color of selected text. Accepts Color name and Hex. If empty, uses default browser color.
selectionTextColorString''Defines the text color of selected text. Accepts Color name and Hex. If empty, uses default browser color.
themeString'light'Defines the theme. Accepts light and dark.
hasBorderRadiusBooleanfalseDefines if the input should have border-radius.
borderRadiusNumber0.5Defines border-radius.
disabledBooleanfalseDefines if the input is disabled
requiredBooleanfalseDefines if the input is required
inputReadonlyBooleanfalseDefines if the input is readonly
inputTextString''Defines the initial input value
inputTypeString'text'Defines the input type. Accepts text, number, email, password.
inputPlaceholderString''Defines the input placeholder text
inputWidthNumber200Defines the input width in pixels
inputStyleString'background'Defines the input style. Accepts background, line, border.
inputUppercaseBooleanfalseDefines if the input text should be uppercase.
inputAutocompleteString'on'Defines the autocomplete attribute. Accepts on and off.
hasTrimBooleanfalseDefines if the input value should be trimmed on blur.
showInputEyeBooleanfalseDefines if the password visibility toggle (eye icon) should be shown. Only works with inputType="password". When inputType="password", the default browser password reveal icon is automatically hidden to allow using the custom eye icon.
inputEyeIconString'๐Ÿซฃ'Defines the icon shown when password is visible.
inputEyeIconHiddenString'๐Ÿ˜Ž'Defines the icon shown when password is hidden.
inputEyeCustomIconBooleanfalseDefines if custom icons should be used via slots instead of emoji.
activeTextStyleString'normal'Defines the text style when input is active/focused. Accepts normal, italic, oblique.
sizeMediaQueryString'sm'Defines the responsive size. Accepts xs, sm, md, lg.
showMsgBooleanfalseDefines if the message should be displayed.
hasMsgBooleanfalseDefines if there is a message to show.
messageString'Default message text'Defines the message text.
hasCustomMsgBooleanfalseDefines if a custom message slot should be used.
textAlignString'left'Defines the text alignment. Accepts left, center, right.
fontFamilyString"'Lato', sans-serif"Defines the font-family
fontSizeString'1.6em'Defines the font-size
fontWeightNumber400Defines the font-weight
fontFamilyMsgString"'Lato', sans-serif"Defines the message font-family
fontSizeMsgString'1em'Defines the message font-size
fontWeightMsgNumber400Defines the message font-weight
textMessageColorString'#f15574'Defines the message text color
lightBgColorString'#f8f8f2'Defines the background color for light theme
lightBgColorFocusString'#eaeaea'Defines the background color when focused for light theme
lightEyeBgColorString'#353734'Defines the eye icon background color for light theme
lightEyeBgColorActiveString'#272936'Defines the eye icon background color when active for light theme
lightDisabledBgColorString'#dfdfd9'Defines the disabled background color for light theme
lightTextColorString'#000000'Defines the text color for light theme
darkBgColorString'#353734'Defines the background color for dark theme
darkBgColorFocusString'#272936'Defines the background color when focused for dark theme
darkEyeBgColorString'#353734'Defines the eye icon background color for dark theme
darkEyeBgColorActiveString'#272936'Defines the eye icon background color when active for dark theme
darkDisabledBgColorString'rgba(40, 42, 54, 1)'Defines the disabled background color for dark theme
darkTextColorString'#000000'Defines the text color for dark theme
darkDisabledEyeBgColorString'rgba(68, 71, 90, 0.3)'Defines the disabled eye icon background color for dark theme
lightDisabledEyeBgColorString'rgba(53, 55, 52, 0.3)'Defines the disabled eye icon background color for light theme
hasIconBooleanfalseDefines if a custom icon should be displayed. When true, shows an icon slot on the left or right side of the input.
iconWidthNumber32Defines the icon width in pixels
iconDirectionString'left'Defines the icon position. Accepts left and right.
iconPaddingString'5px 10px'Defines the icon padding. Must be two space-separated values (e.g., "5px 10px").
iconPaddingInputNumber35Defines the input padding when icon is present. Adds padding to the side where the icon is positioned.
iconMarginString'0'Defines the icon margin
iconLightTextColorString'#f8f8f2'Defines the icon text color for light theme
iconDarkTextColorString'#f8f8f2'Defines the icon text color for dark theme
iconLightBgColorString'#353734'Defines the icon background color for light theme
iconLightBgColorActiveString'#272936'Defines the icon background color when active for light theme
iconDarkBgColorString'#353734'Defines the icon background color for dark theme
iconDarkBgColorActiveString'#272936'Defines the icon background color when active for dark theme
iconDarkDisabledBgColorString'rgba(68, 71, 90, 0.3)'Defines the disabled icon background color for dark theme
iconLightDisabledBgColorString'rgba(53, 55, 52, 0.3)'Defines the disabled icon background color for light theme
iconBorderRadiusNumber0Defines the border-radius for the icon
iconSizeNumber1Defines the icon size multiplier

Events

nameReturn typeDescription
current-valuevalueFired when the input value changes, returns the current value.
changedvalueFired when the input value changes, returns the current value.
focusednothingFired when the input receives focus.
blurrednothingFired when the input loses focus.
show-input-eyebooleanFired when the password visibility toggle is clicked, returns the visibility state.
clickednothingFired when the input container is clicked.
enteredvalueFired when the Enter key is pressed, returns the current value.

Slots

The component has slots for custom content:

message

Custom message slot for displaying validation messages or other information.

<template>
  <NbInput
    nb-id="input1"
    input-name="email"
    :show-msg="true"
    :has-msg="true"
    :has-custom-msg="true"
  >
    <template #message>
      <div class="custom-error">Please enter a valid email address</div>
    </template>
  </NbInput>
</template>

eye-icon-show

Custom icon slot for when password is visible (only when inputEyeCustomIcon is true).

<template>
  <NbInput
    nb-id="input1"
    input-name="password"
    input-type="password"
    :show-input-eye="true"
    :input-eye-custom-icon="true"
  >
    <template #eye-icon-show>
      <span>๐Ÿ‘๏ธ</span>
    </template>
    <template #eye-icon-hidden>
      <span>๐Ÿ™ˆ</span>
    </template>
  </NbInput>
</template>

eye-icon-hidden

Custom icon slot for when password is hidden (only when inputEyeCustomIcon is true).

icon

Custom icon slot for displaying an icon inside the input (only when hasIcon is true).

<template>
  <NbInput
    nb-id="input1"
    input-name="search"
    :has-icon="true"
    icon-direction="left"
    icon-padding="10px 15px"
    :icon-padding-input="40"
    icon-light-bg-color="#353734"
    icon-dark-bg-color="#353734"
  >
    <template #icon>
      <span>๐Ÿ”</span>
    </template>
  </NbInput>
</template>