themesberg / flowbite-react

Official React components built for Flowbite and Tailwind CSS
https://flowbite-react.com
MIT License
1.77k stars 395 forks source link

The Spinner in Button with `isProcessing` prop should be colored according the Button color #1301

Open MiroslavPetrik opened 3 months ago

MiroslavPetrik commented 3 months ago

Steps to reproduce

  1. Create colored button with a spinner:
    <Button color="failure" isProcessing />

Current behavior

The internal Spinner has the default color.

Expected behavior

The internal Spinner has the darker shade of the button color.

Context

The Spinner looks off, as it appears unstyled. The original flowbite does have only the default color button in loading mode, so this is undefined, but I believe it's best to style it.

Solution

I would use the theme prop, and supply a map of darker colors, e.g. instead of the default 600 I would use 800:

const innerSpinnerTheme: FlowbiteSpinnerTheme = {
 color: {
    failure: 'fill-red-800',
    gray: 'fill-gray-800',
    info: 'fill-cyan-800',
    pink: 'fill-pink-800',
    purple: 'fill-purple-800',
    success: 'fill-green-800',
    warning: 'fill-yellow-800',
  },
}

// Button.tsx
<Spinner color={color} theme={innerSpinnerTheme} />