Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theming #33

Open
widianapw opened this issue Apr 8, 2022 · 5 comments
Open

Theming #33

widianapw opened this issue Apr 8, 2022 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@widianapw
Copy link

Capability to set the theme for the whole application

@yamankatby yamankatby added the documentation Improvements or additions to documentation label Apr 9, 2022
@yamankatby
Copy link
Owner

Hi Widiana,
Thank you for reporting this issue. Indeed this is not a feature request since there is already a way to do this. It just needs to be added to the documentation.

You have to wrap your app in the Provider component:

import { Provider, defaultTheme } from "@react-native-material/core";

const App = () => (
  <Provider
    theme={{
      // extend the default theme
      ...defaultTheme,
      palette: {
        ...defaultTheme.palette,
        // override the primary color
        primary: { main: "red", on: "white" },
      },
    }}
  >
    ...
  </Provider>
);

export default App;

If you have time and you would like to help please make a PR to the documentation repo and add Theming page.

@Pika-Pool
Copy link

@yamankatby , could you please explain what is the meaning of main and on properties in palette, and when do we use each of them?

@yamankatby
Copy link
Owner

Hi @Pika-Pool,

The main and on terms are defined by Material design 2, see https://material.io/design/color/the-color-system.html#color-theme-creation.

Simply the main is the color itself and the on is the color to be used on top of the color

Group 8
.

@Drealler
Copy link

Drealler commented Jul 8, 2022

Hi, I tried this solution and got this error in typescript.
Looks like the children is missing in the type definition.

image

Edit:
Is npm version outdated?

@Iryn-e
Copy link

Iryn-e commented Sep 6, 2022

Hi, I tried this solution and got this error in typescript. Looks like the children is missing in the type definition.

image

Edit: Is npm version outdated?

I'm having the same issue when using typescript as the base of the application when it comes to wrapping my entire app with (As in I see the same error message as @Drealler here). However while I am able to change the color of the appbar, I don't think there is a way of easily changing the background color of list items, manually or otherwise.
Here is what I get on an appbar and a list of items with the provider as:

        <Provider
            theme={{
                ...defaultTheme,
                palette: {
                    ...defaultTheme.palette,
                    primary: {main: "red", on: "yellow"}

                }
            }}
        >

![1662482504010](https://user-images.githubusercontent.com/76730458/188693886-3ed04ce5-e333-416a-9493-6aa1bcc0d3ac.JPEG =250x250)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants