To implement a dark mode for FilePond when using Tailwind CSS with the darkMode: 'class' configuration, you can define dark mode styles within your custom CSS file. You'll need to prefix your dark mode styles with .dark to ensure they are applied when the dark class is added to your document's html or body element.
Here's how you can modify your existing CSS to support dark mode for FilePond:
/* Default light theme styles */
.filepond--panel-root {
background-color: #eee;
/* ... other styles ... */
}
/* ... other default light theme styles ... */
/* Dark theme styles */
.dark .filepond--panel-root {
background-color: #333; /* Dark background for the panel */
/* ... other dark styles ... */
}
.dark .filepond--drop-label {
color: #ddd; /* Lighter text color for dark mode */
}
.dark .filepond--label-action {
text-decoration-color: #ccc; /* Lighter underline color for "Browse" button */
}
.dark .filepond--item-panel {
background-color: #444; /* Dark background for file items */
}
.dark .filepond--drip-blob {
background-color: #555; /* Dark background for the drop circle */
}
.dark .filepond--file-action-button {
background-color: rgba(255, 255, 255, 0.5); /* Lighter background for action buttons */
color: black; /* Dark text/icon color for action buttons */
}
/* ... other dark theme styles ... */
/* You can also customize the colors for error and success states in dark mode */
.dark [data-filepond-item-state*='error'] .filepond--item-panel {
background-color: #ff5555; /* Darker red for errors */
}
.dark [data-filepond-item-state='processing-complete'] .filepond--item-panel {
background-color: #55ff55; /* Darker green for success */
}
Make sure that your switcher.js script correctly toggles the dark class on the html or body element when the theme is switched. The CSS styles prefixed with .dark will then be applied automatically.
Additionally, ensure that your @push('styles') section in the Blade file includes the custom CSS file that contains these dark mode styles. If you have separate CSS files for light and dark themes, you may need to dynamically load the appropriate file based on the current theme.
Lastly, verify that the FilePond instance is initialized after the theme has been determined and applied, so that FilePond can pick up the correct initial styles. If necessary, you can refresh FilePond's styles after a theme change by calling pond.redraw() or reinitializing the FilePond instance.