botan
botan

Reputation: 1

How to set the color of text entered in a FormKit input in Vue.js using Tailwind CSS?

I'm working on a Vue.js project where I'm using FormKit to manage forms and Tailwind CSS for styling. However, I am facing an issue with the color of text entered into an input. The text I enter in the field appears in the same color as the placeholder, which is a light tone, while I would like the text entered to be darker.

Here is a snippet of code where I am configuring my input:

<script setup lang="ts">
import LogoAgilis from '@icons/LogoAgilis.vue'
import { reactive } from 'vue'
import router from '~/router'
import { useAuthStore } from '~/stores/auth'

const authStore = useAuthStore()

const credentials = reactive({
  email: '',
  password: '',
})

const { execute: login, isFetching: isLoadingLogin } = authStore.login(credentials)

function handleSubmit() {
  login()
    .then(() => {
      router.push('/organizations')
    })
}
</script>

<template>
  <div class="bg-white p-8 shadow rounded-lg w-80">
    <form
      class="space-y-4"
      @submit.prevent="handleSubmit"
    >
      <div class="flex justify-center items-center gap-1">
        <LogoAgilis
          :size="48"
          fill="#8d00ec"
        />
      </div>

      <div>
        <label
          for="email"
          class="block text-sm font-medium leading-6 text-neutral-800"
        >
          Email
        </label>
        <div class="mt-2">
          <InputEmail
            v-model="credentials.email"
            name="email"
            validation="required"
            placeholder="[email protected]"
            class="block w-full rounded-md indent-2 border-0 py-1.5 text-neutral-800 shadow-sm ring-1 ring-inset ring-neutral-300 placeholder:text-neutral-400 focus:outline-2 focus:outline-inset focus:outline-electric-violet-600 sm:text-sm sm:leading-6"
            :inputProps="{ class: 'text-neutral-900' }"
          />
        </div>
      </div>

      <div>
        <label
          for="password"
          class="block text-sm font-medium leading-6 text-neutral-800"
        >
          Senha
        </label>
        <div class="mt-2">
          <InputPassword
            v-model="credentials.password"
            name="password"
            validation="required"
            class="block w-full rounded-md indent-2 border-0 py-1.5 text-neutral-800 shadow-sm ring-1 ring-inset ring-neutral-300 placeholder:text-neutral-400 focus:outline-2 focus:outline-inset focus:outline-electric-violet-600 sm:text-sm sm:leading-6"
          />
        </div>
        <RouterLink
          to="/recover"
          class="font-medium text-sm text-electric-violet-600 hover:text-electric-violet-500"
        >
          Esqueceu sua senha?
        </RouterLink>
      </div>

      <div>
        <button
          :disabled="isLoadingLogin"
          type="submit"
          class="flex w-full justify-center rounded-md bg-electric-violet-500 px-3 py-1.5 text-sm font-medium leading-6 text-white shadow-sm hover:bg-electric-violet-600 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-electric-violet-600"
        >
          Entrar
        </button>
      </div>
    </form>

    <p class="mt-6 text-center text-sm text-neutral-600 font-medium">
      Usuário novo?
      <RouterLink
        to="/register"
        class="font-semibold mx-1 leading-6 text-electric-violet-600 hover:text-electric-violet-500"
      >
        Cadastre-se
      </RouterLink>
    </p>
  </div>
</template>

Currently, I am using the following configurations for FormKit:

import { pt } from '@formkit/i18n';
import { defaultConfig } from '@formkit/vue';
import { rootClasses } from './formkit.theme';

export default defaultConfig({
  locales: { pt },
  locale: 'pt',
  config: {
    rootClasses,
  },
});

What I've already tried:

  1. Add different color classes to the input, like text-neutral-900, but this had no effect.
  2. Inspecting the element in the browser to check which styles are being applied, but I couldn't find the reason why the color of the text I typed is the same as the placeholder.

How can I ensure that the color of the text entered into the FormKit input is different from the placeholder color? Is there a way to set this color correctly using Tailwind CSS in conjunction with FormKit? Any suggestions on how to customize the styles of FormKit inputs?

Thanks in advance for any help

Upvotes: 0

Views: 55

Answers (0)

Related Questions