marmelab / react-admin

A frontend Framework for single-page applications on top of REST/GraphQL APIs, using TypeScript, React and Material Design
http://marmelab.com/react-admin
MIT License
24.93k stars 5.24k forks source link

[4.0.0-alpha.1]: Style overrides for ReactAdmin components #7079

Closed emulienfou closed 2 years ago

emulienfou commented 2 years ago

What you were expecting:

Should be able to overrides style for ReactAdmin components

What happened instead:

Nothing since to be happening when applying the overrides. I presume this is not implemented yet!

Steps to reproduce:

  1. Create a new theme options object
  2. Add components override for RaSidebar by example
  3. Override background color of the sidebar

Related code:

import { PaletteMode, Components as MuiComponents } from '@mui/material'
import { RaThemeOptions } from 'react-admin'

interface Components extends MuiComponents {
  RaSidebar?: {
    styleOverrides?: any;
    drawerPaper?: any;
  };
  RaMenuItemLink?: {
    styleOverrides?: any;
  }
}

interface ThemeOptions extends RaThemeOptions {
  components: Components
}

export const themeOptions = (mode: PaletteMode): ThemeOptions => ({
  components: {
    RaSidebar: {
      styleOverrides: { root: { backgroundColor: 'red' } }
    },
    RaMenuItemLink: {
      styleOverrides: { root: { padding: 0 } }
    }
  }
})

Other information:

Should be nice to have an updated version of the type RaThemeOptions including ReactAdmin components as well (like I did in the code bellow)!

Environment

fzaninotto commented 2 years ago

Weird, we use style overrides in the ecommerce and crm demos, and they definitely work in next.

https://github.com/marmelab/react-admin/blob/998e254fe09121892b4fc28a97639e50f9c7483b/examples/demo/src/layout/themes.ts#L16-L21

Could you add a link to a CodeSandbow demonstrating the issue?

emulienfou commented 2 years ago

@fzaninotto here is a Codesandbox if you want to check: https://codesandbox.io/s/react-admin-typescript-styles-overrides-tplop

I'm trying to overrides Ra components

djhi commented 2 years ago

Closing this one as duplicate. Thanks for the report