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.

Unable to apply muiTheme with QueryBuilder

See original GitHub issue

First of all, I would like to thank for this amazing library. We have been struggling with our dashboard in which there was a native filter input so that our users can provide mongo-db queries when fetching resources. But its usability was a pain in the ass until we found this library to build nice DSL with forms. Now users can just ask anything without knowing the mongo db query syntax. However, as our frontend theme was only dark, the some default text colors (especially Select) were barely visible so we tried to change it through muiTheme which will be passed to wrapper ThemeProvider for QueryBuilder. To our surprise nothing seems to work, can you please help or at least show guidance how to achieve our goal. Thanks in advance!

I checked query-builder source code, I am not sure but it seems to me there is no way to customize muiTheme from outside. Maybe I missed something! Also I installed query-builder in a new clean react project but got same result!

Here is relevant code snippets from our codebase:

// just tried every possible way, here is just some samples
const muiTheme = createTheme({
  palette: {
    primary: {
      main: "#fff",
      light: "#fff",
    },
    text: {
      primary: "#fff",
      secondary: "#fff",
      disabled: "#fff",
    },
  },
  components: {
    MuiInput: {
      styleOverrides: {
        root: {
          color: "#fff",
        },
      },
    },
    MuiFormControl: {
      styleOverrides: {
        root: {
          color: "#fff",
        },
      },
    },

    MuiSelect: {
      styleOverrides: {
        standard: {
          color: "#fff",
        },
      },
    },
  },
});
<Container>
  <Typography>{filterName} filter</Typography>
  <ThemeProvider theme={muiTheme}>
    <QueryBuilder
      disabled={queryDisabled}
      fields={fields}
      query={query}
      operators={operators}
      combinators={combinators}
      onQueryChange={handleQueryChange}
      controlElements={materialControlElements}
    />
  </ThemeProvider>
</Container>

Here is the screenshot of our dashboard:

ss

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jakeboone02commented, Oct 7, 2022

@humoyun91 @GabriFila @zzoman - I think I’ve finally resolved the issues with @react-querybuilder/material. Can you all try out the “material example” CodeSandbox link in PR #381? (This is the current link.)

Note: if you try it as-is, there will be a slight delay before the MUI components render in place of the default components. The new docs explain how to avoid this flash of non-MUI.

1reaction
jakeboone02commented, Aug 27, 2022

Good news, everyone! I finally cracked the case of the missing theme configurations (see #324) and the issue will be resolved in v5.0, due out soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-awesome-query-builder/CHANGELOG.md at master
User-friendly query builder for React. Contribute to ukrbublik/react-awesome-query-builder development by creating an account on GitHub.
Read more >
Can not apply custom theme in MUI react - Stack Overflow
I tried to apply a custom theme to change color, font, and other styles. But I am unable to apply custom themes with...
Read more >
@react-querybuilder/material - npm
To render MUI-compatible components in the query builder, wrap the <QueryBuilder /> element in <QueryBuilderMaterial /> . import { createTheme, ThemeProvider } ...
Read more >
metosin/cljs-react-material-ui 0.2.49 - cljdoc
metosin/cljs-react-material-ui: Iterop library for material-ui.com Documentation for metosin/cljs-react-material-ui v0.2.49 on cljdoc.
Read more >
Theming - Material UI - MUI
Themes let you apply a consistent tone to your app. ... When using MUI's theme with MUI System or any other styling solution,...
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