Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class overriding (for text color here) does not work for flux:input #214

Open
jensolafkoch opened this issue Oct 1, 2024 · 3 comments
Open

Comments

@jensolafkoch
Copy link

Not sure this is a bug, but could be.

I try to override the text color for an input field with for example !text-red-600, but after a build nothing changes.

<flux:input
   type="text"
   label="Some label"
   value="{{ $someVar }}"
   class="
    !text-red-600
   "
/>

The custom class is applied by Flux to the container div for the input field, not the input field itself - a bug?

If you look at the source code views/flux/input/index you find:

<div class="w-full relative block group/input !text-red-600 placeholder-gray-300" data-flux-input="">
<input type="text" class="…" …>

That does not work for the child div's.

(Besides the text in the field itself, I also tried to change the label text color but found no way to do it.)

@joshhanley
Copy link
Member

I just tested with the long form way too, using the code below, and it didn't work either. It still puts the text colour class on the input wrapping div.

<flux:field>
    <flux:label>Some label</flux:label>

    <flux:input type="text" value="value" class="!text-red-600" />
</flux:field>

@MartijnCuppens
Copy link

The [&>[data-flux-control]] modifier can help you out here.

<flux:input class="[&>[data-flux-control]]:text-red-500" value="I'm red" />

But the behaviour is a little inconsistent. For textarea's or selects, you'll need !text-red-500:

<flux:textarea class="!text-red-500" required label="I'm red" />

@jensolafkoch
Copy link
Author

@MartijnCuppens

Thanks a lot! :-) Well, inconsistent indeed, and not documented at all, I think. I wish it was. :-)

Fiddling with overrides in situations which are a bit off the beaten path is a really inconvenient part of working with Flux ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants