unfoldadmin / django-unfold

Modern Django admin theme for seamless interface development
https://unfoldadmin.com
MIT License
1.04k stars 96 forks source link

feat: Enable overriding widget classes #341

Closed HT-Moh closed 1 month ago

HT-Moh commented 1 month ago

Usage: settings.py

BASE_CLASSES = [
  'border',
  'bg-white',
  'font-medium',
  'rounded-md',
  'shadow-sm',
  'text-gray-500',
  'text-sm',
  'focus:ring',
  'focus:ring-primary-300',
  'focus:border-primary-600',
  'focus:outline-none',
  'group-[.errors]:border-red-600',
  'group-[.errors]:focus:ring-red-200',
  'dark:bg-gray-900',
  'dark:border-gray-700',
  'dark:text-gray-400',
  'dark:focus:border-primary-600',
  'dark:focus:ring-primary-700',
  'dark:focus:ring-opacity-50',
  'dark:group-[.errors]:border-red-500',
  'dark:group-[.errors]:focus:ring-red-600/40',
]

SELECT_CLASSES = [
  *BASE_CLASSES,
  'px-3',
  'py-2',
  'pr-8',
  'flex-grow',
  'max-w-2xl',
  'appearance-none',
  'truncate',
]

UNFOLD = {
  'SITE_TITLE': "Site name",
  'SITE_HEADER': None
  'SELECT_CLASSES': SELECT_CLASSES,
}

You can change classed by adding them to UNFOLD

340

lukasvinclav commented 1 month ago

@HT-Moh this is actually what I'm already considering to implement and below you can see one of the first steps making CSS classes available in all templates where it would be possible to change them in settings.py. But this change will require much more work. All form elements have to use these classes what is not the case right now (some inputs have hardcoded CSS in templates) so a lot of refactoring and UI redesign will be required.

https://github.com/unfoldadmin/django-unfold/blob/main/src/unfold/sites.py#L56

At the moment, I'm recommending you to change the visual of inputs by loading of your custom CSS file

HT-Moh commented 1 month ago

@lukasvinclav thanks, yeah but this PR made it possible now to change it on the settings. 10 files has been refactored and the necessary changes on the sites.py is already done.