ach
ach

Reputation: 73

Non-prop attribute label not working whilst style does

I have a custom component called PasswordInput, defined as

<template>
  <v-text-field
    :type="showPassword ? 'text' : 'password'"
    prepend-icon="mdi-lock"
    :append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
    @click:append="showPassword = !showPassword"
  />
</template>

<script>
export default {
  data() {
    return {
      showPassword: false
    }
  }
}
</script>

and used like this

<password-input
  label="Password"
  style="background-color:red"
></password-input>

However, although the style is passed to the route element, the label doesn't seem to work, as seen here, pic

Upvotes: 0

Views: 39

Answers (1)

Shivam Singh
Shivam Singh

Reputation: 1731

Bind all attributes to v-text-field that you are applying on the password-input in the parent component.

<v-text-field
 v-bind="$attrs" // <-- Here
 :type="showPassword ? 'text' : 'password'"
 prepend-icon="mdi-lock"
 :append-icon="showPassword ? 'mdi-eye' : 'mdi-eye-off'"
 @click:append="showPassword = !showPassword"
/>

Upvotes: 1

Related Questions