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

[BUG] - Flat variant picks different(wrong?) colors when using custom theme #3915

Open
jbree opened this issue Oct 18, 2024 · 2 comments
Open
Labels
🎨 Scope : Themes / Styles Related to the themes or styles 🐛 Type: Bug Something isn't working

Comments

@jbree
Copy link

jbree commented Oct 18, 2024

NextUI Version

2.4.8

Describe the bug

When creating a theme with nextui, components with variant="flat" choose different colors for themes with custom names (i.e. not "light" or "dark"). I have observed this specifically with Button and Chip.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

when I create a "dark" theme with the following color config, a button with variant="flat" looks as expected:

dark: {
  colors: {
    "warning": {
      "50": "#4a320b",
      "100": "#744e11",
      "200": "#9f6b17",
      "300": "#ca881e",
      "400": "#f5a524",
      "500": "#f7b54a",
      "600": "#f9c571",
      "700": "#fad497",
      "800": "#fce4bd",
      "900": "#fef4e4",
      "foreground": "#000",
      "DEFAULT": "#f5a524"
    }
  }
},

However, when I create and use a theme with a custom name, but identical color values, the button appears to choose the 800 value for text instead of the DEFAULT color, and a different background color as well.

funk: {
  extend: "dark",
  colors: {
    "warning": {
      "50": "#4a320b",
      "100": "#744e11",
      "200": "#9f6b17",
      "300": "#ca881e",
      "400": "#f5a524",
      "500": "#f7b54a",
      "600": "#f9c571",
      "700": "#fad497",
      "800": "#fce4bd",
      "900": "#fef4e4",
      "foreground": "#000",
      "DEFAULT": "#f5a524"
    }
  }
}

Expected behavior

I expected that this button would look identical in either of these themes. Instead, different colors are used for each theme.

Screenshots or Videos

dark (as expected):
image

funk (expected this to look identical to "dark"):
image

Operating System Version

macOS

Browser

Chrome

Copy link

linear bot commented Oct 18, 2024

@jachinte
Copy link

This behavior was introduced in @nextui-org/react@2.4.7:

fix(theme): update flat variant text colors to be accessible by @rileybutterfield in #3738

Before 2.4.7:
before-2 4 7

After 2.4.7:
after-2 4 7

This is how I'm customizing the colors for the dark theme:

default: {
  ...swapColorValues({
    50: '#a1a1aa',
    100: '#909098',
    200: '#7f7f86',
    300: '#6e6e74',
    400: '#5d5d62',
    500: '#4c4c50',
    600: '#3b3b3e',
    700: '#2a2a2c',
    800: '#19191a',
    900: '#09090b',
  }),
},

The 200 value is applied by these changes. Before, it was taking text-default-foreground (cf. https://github.com/nextui-org/nextui/pull/3738/files#diff-3708626db65699f2a4cade1f64846d74dbb3c0ee7dd38c11057e18b129a77cecL32)

@rileybutterfield according to your PR, this change is intended to fix the color contrast. However, I believe for flat buttons it was already good: white text over a dark gray background. Is this a bug?

@wingkwong wingkwong added 🐛 Type: Bug Something isn't working 🎨 Scope : Themes / Styles Related to the themes or styles labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎨 Scope : Themes / Styles Related to the themes or styles 🐛 Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants