question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sidebar option in theming doesn't work

See original GitHub issue

What you were expecting: As docs are saying in order to customise the sidebar and keep it responsive, you have to pass the settings in a theme prop in Admin:

import { createMuiTheme } from '@material-ui/core/styles';

const theme = createMuiTheme({
    sidebar: {
        width: 300, // The default value is 240
        closedWidth: 70, // The default value is 55
    },
});

const App = () => (
    <Admin theme={theme} dataProvider={simpleRestProvider('http://path.to.my.api')}>
        // ...
    </Admin>
);

What happened instead: Unfortunately, it didn’t work, because createMuiTheme doesn’t support sidebar option.

I have found the same question in StackOverflow and there was a solution not to wrap it around createMuiTheme:

const theme = {
  sidebar: {
    width: 220, 
    closedWidth: 55, 
  },
} 

However, it doesn’t work either. I got the following error:

Type '{ sidebar: { width: number; closedWidth: number; }; }' has no properties in common with type 'ThemeOptions'.

Steps to reproduce:

Modify App.tsx with the code from docs or the code in Related Code and you will see a compile error. I use Typescript. Apparently it doesn’t work with TS. Related code: App.tsx:

import * as React from 'react'
import { Admin, Resource} from 'react-admin';
import dataProvider from './dataProvider';
import { cacheDataProviderProxy } from 'react-admin';
import { FeedList } from './components/feeds'
import Layout from './components/layout';
import { CollectionsBookmark } from '@material-ui/icons';

const customDataProvider = cacheDataProviderProxy(dataProvider('http://localhost:8080/api/v1'));

const theme = {
  sidebar: {
    width: 220,
    closedWidth: 55,
  },
}

const App = () => (
    <Admin
        theme={theme}
        dataProvider={customDataProvider}
        loginPage={false}
        title="Title"
        layout={Layout}>
        <Resource name="feeds" list={FeedList} icon={CollectionsBookmark}/>
    </Admin>
);

export default App;

Environment

  • React-admin version: ^3.9.4
  • React version: ^16.13.1
  • Browser: Google Chrome
  • Stack trace (in case of a JS error):
TypeScript error in /Users/Mariaefi/Documents/react/admin-is/src/App.tsx(21,9):
Type '{ sidebar: { width: number; closedWidth: number; }; }' has no properties in common with type 'ThemeOptions'.  TS2559

    19 | const App = () => (
    20 |     <Admin
  > 21 |         theme={theme}
       |         ^
    22 |         dataProvider={customDataProvider}
    23 |         loginPage={false}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mariaefi29commented, Oct 20, 2020

@djhi Thank you so much!

It works! I added ..defaultTheme though as well, because without that it changes colors again.

I’ll stay tuned for provided types then! Thanks again for your help!

I am new to react, so it’s difficult more me to dig such things on my own yet(

0reactions
mariaefi29commented, Oct 21, 2020

Thank you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sidebar menu options don't appear - WordPress.org
I tried toggling some settings on and off and resaving, but the sidebar is still blank. I'd really like to fix it, but...
Read more >
ISSUE: Sidebar is not displaying
ISSUE: Sidebar is not displaying. Sidebar controls vary from theme to theme. If the sidebar isn't showing in your theme, check these areas ......
Read more >
How to Fix a Missing Sidebar in WordPress - Elegant Themes
The WordPress missing sidebar issue is actually a pretty common one that has a multitude of possible fixes. Here, we discuss some of...
Read more >
Problem with Sidebar on Parent and Child Theme - Themeco
Hello,. I have a problem with sidebars. My url is: picotera.co wordpress version 3.9.1. Theme version (latest I think..) shortcode plugin version: 2.3.3....
Read more >
Theme-integrated-sidebar doesn't support dark mode ... - GitHub
theme -integrated-sidebar is an example extension intended to show a sidebar that reflects the colors of the current browser theme.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found