Having trouble with the display of styles on Material UI Cards?

I am currently attempting to customize the default Material UI classes by using useStyles and applying a classname of titleSection. My goal is to make the titleSection bold and in Roboto font, but unfortunately, those styles are not being applied.

Below is my card:

function ImageCard(props: ImageCardProps) {
  const classes = useStyles();

  return (
    <Card>

      <CardHeader title={props.title} className={classes.titleSection} />
 
    </Card>
  );
}

Here is how I have defined my useStyles:

const useStyles = makeStyles((theme: Theme) =>
  createStyles({
    
    
    titleSection:{
        paddingBottom: 0,
        fontWeight:'bolder',
        fontFamily:'Roboto',
    },
  })
);

Answer №1

If you're looking for a comprehensive explanation, the MUI documentation is a great resource: https://material-ui.com/api/card-header/

To customize the title styling using the 'classes' property, target the CSS rule named 'title' that surrounds the typography component.

const useStyles = makeStyles((theme: Theme) =>
  createStyles({
    title: {
      paddingBottom: 0,
      fontWeight: 'bolder',
      fontFamily: 'Roboto, sans-serif',
    },
  })
);

function ImageCard(props: ImageCardProps) {
  const classes = useStyles();

  return (
    <Card>
      <CardHeader title={props.title} classes={{ title: classes.title }} />
    </Card>
  );
}

If you prefer to apply these changes globally, explore the MUI theme object and theme override documentation:

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

Customizing the hover behavior of a div element without causing displacement of surrounding elements

I am facing an issue where the descriptions in my list of 100 items are longer than the width of the div, causing the text to be cut off. I want to display the full description on hover without affecting the layout of other items. Currently, when I hover o ...

What is the best way to vertically align a container beneath a navbar without triggering the appearance of a scrollbar?

I'm in the process of developing an application using Bootstrap 4. The app features a navigation bar and a container located beneath it. Below you'll find the structure of the application: <body> <div id="root"> ...

Troubleshooting Issue: Unable to Collapse Bootstrap Responsive Navbar Button with Custom CSS Modifications

I recently created a responsive HTML page using Bootstrap, then converted it to WordPress and made some custom CSS adjustments. In the original HTML version of the page, the navbar collapse button worked perfectly when the screen was resized. However, afte ...

Is there an expense associated with utilizing `makeStyles` in a component that will be duplicated, such as a list item?

Currently, I have a component called MyListItem that will only be rendered as part of a list. My dilemma lies in whether to localize the const useStyles = makeStyles(...) directly inside MyListItem. If there are 100 list items, this could potentially resul ...

What is the best way to use a button to hide specific divs upon clicking?

Is there a way to use a button onclick event to hide specific divs within a parent div? I've tried using .toggleClass('.AddCSSClassHere') but I'm not sure how to apply it to multiple divs. The jQuery snippet provided only allows me to h ...

Container holding a Material-UI drawer

Is it possible to set the material-ui drawer inside a container in reactjs? I have wrapped my app page in a container with a maximum width of 600px. I want the drawer to start within that container instead of on the body page (picture). The app bar positi ...

How to include padding in HTML elements

Looking for help with aligning this html code equally. <address class="address"> <span>Support E-mail:&nbsp;</span><a href="#"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-c ...

Is there a way to retrieve all elements with a specific attribute in GraphQL?

I have a file named countryData.json containing some JSON data structured like this: { "info":"success", "stats": [{ "id":"1", "name":"USA", "type":"WEST" }, //... Utilizing graphQL to retrieve this data, I've defined an object type fo ...

How do I define the type of a class property in TypeScript?

I am currently working on my own implementation of Client-side rendering and I need to define the data structure for my route object. The format is shown below: import Post from './Post' export const route = { path: '/post', c ...

Ensuring proper alignment between labels and input

How can I align a label and a range input field on the same line? I have tried using display: inline-block, but it does not seem to work. There doesn't appear to be any conflicting styles, and all sources indicate that this approach should be effect ...

Cross-origin error triggered by using an external API within a ReactJS application

I'm facing a common CORS issue in my application while trying to call an API. The API I am attempting to access can be found here: https://github.com/nickypangers/passport-visa-api Below is the code snippet used for making the API call: const getVi ...

Interactive front end design for decision trees

On the front end, I aim to enable users to influence the outcome of a Decision Tree based on their selections. For my Django-React App, I have adopted the style and tree example from the codeplayer. You can find it here: I am tasked with creating an unor ...

Not every situation calls for the same type of styling

I am struggling to override the CSS for <h1> and <h2> using specific selectors only. The changes are only being applied to one class, with <h1> changing color to green but not <h2>. Can someone please assist me in identifying where ...

Extracting the number of likes from each post on a specific profile using Python scrapy

Here is the code snippet that I am currently working with: #IMPORT THESE PACKAGES import requests import selenium from selenium import webdriver import pandas as pd #OPTIONAL PACKAGE, BUY MAYBE NEEDED from webdriver_manager.chrome import ChromeDriverManage ...

The functionality of the React onClick event seems to be malfunctioning specifically when used in conjunction

I've been working on incorporating a dropdown menu using React. The <Dropdown></Dropdown> element is embedded within the component's return(). <Dropdown> <Dropdown.Toggle className="btn btn-dark"> < ...

Encountering difficulty fetching data from Firestore due to an error message stating 'TypeError: this.store is undefined'

I've been working on retrieving my data collection from Firestore but I've encountered an issue. The error message I'm getting is as follows import React, { Component } from 'react' import Notification from './Notificati ...

React/Redux - Issue with rest operator functionality in component

Here is the initial state I am working with: const initialState = { selectedGroup: {}, groups: { rows: [], total: null }, offset: 0, range: 15, loading: false, error: null } Within a reducer function, I have this case for successful ...

Erasing the content of a text field with the help of a final-form computation tool

I'm attempting to utilize the final-form calculator in order to reset a field whenever another field is modified. In my scenario, there are two fields. Whenever the first field changes, the second field gets reset as expected. However, an issue aris ...

Refresh PHP Calculator Display Once Results are Shown

Currently working on a basic calculator project coded in HTML, CSS, JS, and PHP. Here is a glimpse of it: The user input retrieval is handled by JS, while the actual calculations and result display are taken care of by PHP. I am striving to clear out the ...

background with alternating stripes to decorate the border of a div

Is it possible to give a striped effect to a div element's border using jQuery? Consider the following code snippet: <style type="text/css"> #panel { padding: 50px text-align: center; background-color: #e5eecc; bord ...