Develop and arrange badge components using Material UI

I'm new to material ui and I want to design colored rounded squares with a letter inside placed on a card component, similar to the image below.

https://i.stack.imgur.com/fmdi4.png

As shown in the example, the colored square with "A" acts as a badge on the card component. I would like to achieve the same effect using material ui but I'm unsure where to locate this feature. This is how my current card appears:

https://i.stack.imgur.com/n9yQ6.png

This is the code I have for displaying a component:

import React from 'react';
Grid from '@material-ui/core/Grid';
Card from '@material-ui/core/Card';
makeStyles from '@material-ui/core/styles';
CardContent from '@material-ui/core/CardContent';
Typography from '@material-ui/core/Typography';
Box from '@material-ui/core/Box';
Badge from '@material-ui/core/Badge';
VisibilityIcon from '@material-ui/icons/Visibility';

const useStyles = makeStyles({
cardRoot: {
width:"400px",
fontSize: "1.125rem",
fontWeight:"bold",
lineHeight:"1.5rem",
marginLeft:"50px",
padding:"10px"
},
// More CSS styling...

export default function Job({job}) {

const classes = useStyles();
const bull = <span className={classes.bullet}>•</span>;
return (
<Grid item sm={4} xs={2}>
<Card className={classes.cardRoot}>
<CardContent>
<Box p={1} display="flex" justifyContent="flex-end" flexDirection="row" className={classes.viewContainer}>
<VisibilityIcon></VisibilityIcon>
<Typography component="span"> VIEW DETAILS</Typography>
</Box>
<Box display ="flex" justifyContent="flex-start">
<Box p ={1}>
... // Rest of the code here
</Box>
</Box>

</CardContent>
</Card>

</Grid>
);
}

Your assistance would be greatly appreciated.

Answer №1

To get your Card component to function properly, you must enclose it within the Badge component. Check out this sandbox for an example.

<Badge color="secondary" badgeContent={99}>
        <Card className={classes.cardRoot}>

Answer №2

Take a peek at the Avatar component for some inspiration.

avatar Preview

Here's a simple way to implement it:

 <Avatar src={member.name.substring(0, 1).toUpperCase()} />

You can also customize the shape from rounded to square as needed.

Hoping this helps you out! Have a fantastic day ahead!

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

Best Practices for Organizing Image and JavaScript Files in Your Project

Currently, I am working on a project in Eclipse and I'm unsure about the proper location to store my image files and JavaScript files. Can anyone provide guidance on this matter? Thank you. ...

What could be causing the request body in ExpressJs to be blank?

Using ExpressJs, I have created a simple app that can handle post requests and form submissions. Below is the code snippet from my index.js file: require ('./models/db'); const express = require('express') const app = express() const bo ...

Image optimization using media queries

In the scenario where the maximum width is 1220px, I want to change the main display to column. This is what I have implemented: @media (max-width: 1220px) { .main { flex-direction: column; } However, when the width reaches 1220px, the image disap ...

Can the @keyframes in CSS3 be modified?

Exploring CSS3 animations has been a fun project for me, and I want to push the boundaries of what is possible. Currently, I have an infinite animation cycle that is working perfectly. However, I'm curious if it's possible to dynamically change ...

What could be causing the image to not display as completely rounded-full in NextJS13 when using tailwind?

I tried to make an image round using the Image Component in NextJS13, but I ran into some issues Additionally, when I styled it with Tailwind, the full style didn't seem to take effect <div className="h-64 w-96 relative"> <I ...

Sending data from a child component to a parent component in React

Trying to figure out how to pass the returned value of function appColor from the WeatherForecast component into a property, and then passing that property from WeatherForecast to the className of the app component. I'm new to React, so not sure how t ...

Can one track the moment when a user clicks on an advertisement within a YouTube video?

Can we track when a user clicks on an advertisement within a YouTube video? We have integrated the YouTube API v2 into our website, allowing users to watch videos. The issue is that when a user clicks on an advertisement, the YouTube video pauses automat ...

How to automatically redirect empty routes to a specific route in Next.js

When visiting a non-existent endpoint in Next.js, I receive a 404 error. What I actually want is for all unused routes to automatically redirect to a default route; specifically, the landing page. I've spent more than an hour trying to figure this ou ...

What is the most effective method to create an application that displays users' GPS coordinates using React and Express?

I'm planning to create an app that displays users' GPS coordinates by sending the data through a POST request to the server and storing it in a database. The user will input their username, then a Google map will display their current position. I ...

How can we map a promise that resolves to foo to a new promise that resolves to bar?

I am working on a function that uses an XMLHttpRequest to retrieve data and returns a promise with the response. But now I want to modify it so that the promise only contains a specific string from the response. Instead of resolving to response = {status ...

Samsung devices exclusively showcase background in responsive design

I am encountering a major problem with my website design, specifically with its compatibility on mobile devices. To ensure its responsiveness, I have tested the design on my iPhone, iPad, and Windows Phone. Unfortunately, since I lack an Android device, I ...

Is there a method in VBA to access elements generated by javascript code?

After spending several hours conducting thorough research on Google (including browsing StackOverflow), I've been trying to find a method that would allow me to target HTML elements generated by JavaScript in VBA. For instance, using ie.Document.getE ...

The remnants of the previous state linger on in React, even after new updates have been

This React application features a dynamic list with the ability to add and delete tasks. The list is maintained in both this.state.tasks and a database. When rendering, the code maps through the tasks array to display each task as a GridListTile component ...

Having trouble getting the smooth scroll-behavior to work properly in Tailwind CSS?

I've been working on my portfolio using next.js and tailwind CSS. I've added scroll-behavior: smooth in the globals.css file, and in the Navbar, I used https://i.stack.imgur.com/wqb4t.png I really want to achieve that smooth scrolling effect thr ...

Ensuring the presence of a bootstrap angular alert with protractor and cucumberJS

I am currently utilizing protractor, cucumberJS, and chai-as-promised for testing. There is a message (bootstrap alert of angularJS) that displays in the DOM when a specific button is clicked. This message disappears from the DOM after 6000 milliseconds. ...

`Problem with CSS in Firefox, functions properly in Chrome`

Can someone please check to see if they can find what I'm overlooking? It's working perfectly in Chrome 10 but not in Firefox 4. The aim is for it to look like an iPhone keyboard. http://jsfiddle.net/pfqdr/ UPDATE: http://jsfiddle.net/pfqdr/6/ ...

List organized in two columns utilizing the data-* attribute

Is it possible to display a list in a two-column format based on a data attribute of each item? <ul> <li data-list="general_results">general text1</li> <li data-list="general_results">general text2</li> <li dat ...

After removing the timezone from the timestamp log, why is it now showing as one day behind?

Within my programming, I store a timestamp in the variable 'var timeStamp = finalData.obj.followers[0].timestp;', which currently outputs '2020-04-15T00:00:00.000Z.' To extract only the date and remove the time zone information, I util ...

Adding complex JSON format to an HTML table involves formatting the data correctly and then using

Utilizing AJAX, I fetched a JSON response and am now looking to map the JSON data into an HTML table structured like this: { "records": [{ "type_id": 000001, "type_desc": "AAAAAA", "type_createby": "Adam" }, { "type ...

Accept input from the user N times using the Node.js console

Hey there, I'm facing a challenge with getting user input in Node.js and running a function on each input a specified number of times. Unfortunately, using either a while or for loop doesn't seem to be the solution. Any suggestions or guidance w ...