Harnessing the Power of Material UI to Revolutionize Amplify Theming

I am currently developing a React application with Material-UI and Amplify UI Components. I am looking to customize the Amplify theming.

By following the guidance provided on Amplify UI Components Customization, I have been able to override CSS variables in a separate custom CSS file.

CustomCss.css
-------------
:root {
  --amplify-primary-tint: rgba(89, 210, 188, 1);
  --amplify-primary-color: rgba(20, 160, 140, 1);
  --amplify-primary-shade: rgba(0, 113, 95, 1);
}

This custom CSS file can then be imported into my application.

App.js
------
import React from 'react';
import { CssBaseline } from '@material-ui/core';
import { ThemeProvider } from '@material-ui/core/styles';
import { withAuthenticator } from '@aws-amplify/ui-react';
import theme from "./theme";
import './CustomCss.css';

const App = () => {
  return (
    <ThemeProvider theme={theme}>
      <CssBaseline />
      ...
    </ThemeProvider>
  );
}

export default withAuthenticator(App);

However, I would like to streamline the process by overriding the Amplify theming within the same location where I define the Material-UI theme.

theme.js
--------
import { createMuiTheme } from '@material-ui/core/styles'

export const theme = createMuiTheme({
  'palette': {
    'primary': {
      'light': 'rgba(89, 210, 188, 1)',
      'main': 'rgba(20, 160, 140, 1)',
      'dark': 'rgba(0, 113, 95, 1)',
    },
  },
});

export default theme;

Is there a way to seamlessly override Amplify theming with Material-UI?

Answer №1

Issue with Styling in New AWS Amplify Components

If you are experiencing problems with styling in the latest version of @aws-amplify/ui-react, check out this ongoing discussion on GitHub: https://github.com/aws-amplify/docs/issues/2484

A user is requesting support for a feature that would allow the usage of a theme object similar to what was available in aws-amplify-react.

  • The example they provide that is currently not functioning as expected in the newer release is:
const MyTheme = {
   formSection: { 'display': 'none' }
}

// define class App { ... }

export default withAuthenticator(App, { theme: MyTheme })

It seems that the new amplify components only accept CSS styles at present and do not support applying styles through JavaScript objects. The issue remains open for now.

On a side note, an attempt to customize the UI using codesandbox and following suggestions from this StackOverflow thread did not yield successful results. It appears that the new components in @aws-amplify/ui-react do not handle styles in the same way as aws-amplify-react.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Shifting from Redux to React-Query: A step-by-step guide

I am currently delving into react-query but I find it quite challenging to grasp. Can someone please provide an example based on the code snippet below? The following code includes an action and a reducer: export const addHighlighting = parent_id => di ...

Tips on configuring commas in the Prettier extension within Visual Studio Code

My CSS file is causing me some trouble. I am trying to configure Prettier in VS Code so that when I write a comma, the selector I entered stays in line with the previous one. However, whenever I save the file, the selector gets moved to the next line. My ...

Component does not render on router.push('/page') without reloading first

After a successful login, I am storing the user token in browser cookies and using router.push('/dashboard') to redirect the user to their dashboard. However, the '/dashboard' page does not display any components until a manual reload i ...

Create waypoints on multiple elements

I am working on implementing a unique feature using a div tag with the class "dipper." <div class = "dipper"> <p>Peekaboo</p> </div> As part of this implementation, I have included a script that triggers the display of the "dipper ...

Accessing palette.secondary.light in Material UI v5 using TypeScript is a simple process

Looking to incorporate the palette.secondary.light color into the login button. My project includes demo.tsx and theme.tsx files. Here is the link to the CodeSandbox for reference. Any assistance would be greatly appreciated! View code in CodeSandbox ...

Make sure not to establish a Socket.io connection more than once

I am currently using React on the frontend and Express on the backend. The code snippet below is what I have written to establish a connection between the client and the server: import React, { useEffect, useState } from 'react'; import { io } f ...

`CSS alignment problems with multiple images`

Recently, I delved into the world of CSS and HTML. I created an application with pages designed using these languages. Here are the images representing my pages: and the second one is the user page, which serves as the home page. Below is a snippet of my ...

Display all items with pagination in a Material UI Table using React

I have recently implemented pagination in a react data table to handle a large number of entries. I wanted to add an option to display all entries by selecting "all" in the rowsPerPageOptions dropdown menu. Currently, I am able to show the count of all ent ...

Creating a bordered triangle using only CSS

Looking to create a message holder with a triangular tip bordered shape? I've successfully crafted the tip using two triangles: #triangle-border { width: 0px; height: 0px; border-style: solid; border-width: 0 100px 80px 100px; bor ...

The issue with the page width is occurring due to a bug related to the

When pages contain the AddThis code, they tend to become very wide due to the code itself, resulting in a horizontal scroll bar appearing. However, by removing the code or changing the page direction to LTR, the issue is resolved and the page width return ...

What is the best way to showcase the final div at the top with CSS?

I'm working with 4 separate divs, with the last one acting as a footer. Is there a way to position this last div at the top using CSS? ...

Adjust the background color of children based on the parent's mouseover event

Seeking a solution to fill three bars with varying percentages: <div class="bars" style="width:0%; background-color: red;"> <span class="bar"></span> <span class="bar"></span> <span class="bar"></span> </ ...

What could be causing the data toggle feature in my navbar to not work on Bootstrap?

Here is a code snippet to create a simple collapsible navbar with Bootstrap 5 that includes a logout button. However, the data toggle feature for the logout button doesn't seem to work when clicked. Any suggestions on how to fix this? <!DOCTYPE ...

The Dynamic Duo: React Native and Redux

Hey there, I'm just diving into React Native and Redux. I'm working on setting up a simple app state where a counter property increments when a button is pressed. Although no errors are being thrown, the state isn't updating as expected - th ...

Error encountered when attempting to iterate through two TableRows using React Material UI 2 in a

For my first project in React, I'm encountering an issue with rendering my table correctly. My goal is to achieve a layout similar to this: https://i.sstatic.net/jjTsu.png The green brackets represent the content within my loop. However, React is in ...

Using a percentage in CSS translate can result in an image appearing blurry

I am facing a frustrating issue. Whenever I align an image using percentage-based transform translate, it results in a slight blur. This problem is specifically related to percentage alignment. Here is the CSS snippet: img { display: block; height: ...

How to replicate a WordPress menu bar

Embarking on my coding journey, I've completed courses in HTML, PHP, CSS, JavaScript, and MySQL. Now, I've decided to dive into hands-on learning by creating a Wordpress child theme. My current challenge is figuring out how to overlay two differ ...

Is it possible to set a minimum width for browser resizing?

https://i.sstatic.net/0qhjT.png Looking at the image provided, I'm doing a comparison of the minimum resizable widths between my website and GitHub's. Is there a way to enforce a minimum width limit on my website similar to GitHub's? I&apo ...

Improved method for linking two enums with similar appearances

Currently, I use two enums as shown: enum Tab { Approved = "Approved", Pending = "Pending", Sold = "Sold", } enum ProductStatus { Approved = "Approved", Pending = "Pending", Sold = "Sold&q ...

I possess three stylish CSS buttons, however, the other one is accompanied by <br />

I'm struggling to ensure that the three CSS buttons are the same size (using padding) and vertically aligned, as the second button includes a "<br />" which throws off the alignment. I was advised to use flexbox, but I haven't been able to ...