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

More metadata is needed for conditional styling #24

Closed
AruhaMaeda opened this issue Mar 6, 2023 · 2 comments
Closed

More metadata is needed for conditional styling #24

AruhaMaeda opened this issue Mar 6, 2023 · 2 comments

Comments

@AruhaMaeda
Copy link

Hi, this is a great library, and thank you for your development and sharing!

I have a feature request.
I want to change the tag Item styling based on its value.
But I think more metadata is needed to achieve this. (currently "disabled" only)

In my use case,
there are "todo", "in progress", "done" labels.
and want to change its background and text color in order for users to see what is currently selected.

In this case, something like "value" is good

            classNames={{
              tagItem: ({ value, isDisabled }) => {
                if (value === 'todo') {
                  return 'flex text-sm text-yellow-500 border border-slate-300 rounded shadow-sm mx-0.5'
                }
                if (value === 'in progress') {
                  return 'flex text-sm text-red-500 border border-slate-300 rounded shadow-sm mx-0.5'
                }
                if (value === 'done') {
                  return 'flex text-sm text-green-500 border border-slate-300 rounded shadow-sm mx-0.5'
                }
              },
@onesine
Copy link
Owner

onesine commented Mar 6, 2023

Hi @AruhaMaeda 👋

Thanks for using our library and thanks for this feature request.

I think your request is really relevant and should be implemented very soon. It will be available in the next release, most likely within the day.

@onesine onesine closed this as completed in 600407d Mar 6, 2023
@onesine
Copy link
Owner

onesine commented Mar 6, 2023

Hi @AruhaMaeda 👋!

Sorry for the delay. I added some features to the project to make the development phase easier.
The functionality is now available. But you have to upgrade to version 1.8.0.

Now use this code.

classNames={{
  tagItem: ({ item, isDisabled }) => {
    if (item.value === 'todo') {
      return 'flex text-sm text-yellow-500 border border-slate-300 rounded shadow-sm mx-0.5'
    }
    if (item.value === 'in progress') {
      return 'flex text-sm text-red-500 border border-slate-300 rounded shadow-sm mx-0.5'
    }
    if (item.value === 'done') {
      return 'flex text-sm text-green-500 border border-slate-300 rounded shadow-sm mx-0.5'
    }
},

Item contains all information of the tag.

https://github.com/onesine/react-tailwindcss-select#all-keys

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

No branches or pull requests

2 participants