Incorporate photo thumbnails into Material UI cards

I am currently using Material-UI card component in my React web application. The card is quite plain and only has a title. I would like to enhance it by adding a thumbnail on the left side of the card, followed by the title, similar to how song lists are displayed in some apps. I have tried implementing this but haven't been successful. Is there a way to add an image as a thumbnail to the card's leftmost side? I want the thumbnail height to match the card's height and for it to start from the left edge without any margin. Can someone provide assistance?

Below is the code for the current card:

render(){  
    return (
        <div>
            <MuiThemeProvider>
                <Card style= {{marginBottom: 2}} 
                      onTouchTap={() => {this.props.handleClick(this.props.id)}}
                      zDepth={this.state.shadow}>
                    <CardHeader
                      style={{fontFamily: 'Roboto, sans-serif', fontWeight:600}}
                        title={this.props.title}
                        //subtitle={value.description}
                        actAsExpander={false}
                        showExpandableButton={false}
                    />
                </Card>
            </MuiThemeProvider>
        </div>
    );
}

Answer №1

If you want a custom component, consider creating your own or utilizing List/ListItem with a square image on the leftAvatar:

For an example, check out this jsFiddle: https://jsfiddle.net/42f81uvv/1/

<List style={{ width: 400 }}>
  <ListItem
    innerDivStyle={{ paddingLeft: 80 }}
    leftAvatar={
      <img style={{ height: '100%', margin: -16 }} src="https://zartnerds.files.wordpress.com/2015/10/thumbnail.png" />
    }
    primaryText="Some Title"
    secondaryText="That's a good looking thumbnail"
    />
</List>

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

conceal the act of pushing

After adding a property in a push function to toggle between hiding the label and showing the input, there is a need to reverse this action when the user clicks on Save changes. This can be achieved by using the ng-hide directive. <tr ng-repeat="pe ...

What is the best way to combine these two arrays in order to generate the desired JSON structure in a React

Is there a way to transform two arrays like these: const age = [31,53,62] const names = ['john', 'sam', 'kathy'] Into the structure shown below: const data = { "children": [ { "id": 1, "name": "john", "age ...

Can't modify the input field (material-ui and react-draggable)

I'm experiencing difficulty entering input into a TextField that is being iterated over an array within the React state. To view the code, please check out the following CodeSandbox URL. You can navigate through the initial page without providing any ...

Styling Labels with CSS Wildcard

I have been using the free NinjaForms plugin on my WordPress site. The default styling for labels is bold, but I prefer them to be lighter. Currently, I achieve this through CSS by targeting individual field IDs. However, this method becomes tedious when a ...

Tips for implementing the datatable method on a dynamically generated table

I have a scenario where I need to dynamically create a table by triggering a button click event. function populateTable() { $.ajax ({ url: 'php/GetData.php', type: 'POST', data: {id:25}, success: f ...

Is there a way to reverse the confirmation of a sweet alert?

Hey there, I'm currently using Sweet Alert to remove a product from my website. I want to implement it with two options - 'ok' and 'cancel'. However, I'm facing an issue where clicking anywhere on the page removes the product ...

Issue: Dispatch function in Redux is failing to be invoked

I'm trying to wrap my mind around this issue and I can't seem to figure out why it's not functioning properly. Here is a simple action that I have: export const GET_EXPENSE_LIST = "GET_EXPENSE_LIST" export const getExpenseList = () => ...

Interacting with a WebGL globe: accessing database information and displaying pop-up windows when clicking on specific locations on the globe

I am working on creating a WebGL Globe similar to the one found at this link: Currently, I have been using this example as a reference point: Here are the specific project requirements that I am aiming to achieve: The website needs to be able to manage ...

Could it be that the lower right corner of the border has vanished?

Some items in my list have borders on the left and right sides, but I am experiencing unexpected white gaps only on the right side. I have been unable to identify the issue despite going through my code multiple times. Any assistance would be highly appre ...

The implementation of Axios cancel token failed to function properly in a real-time search feature within a React application

I'm currently developing a dynamic search feature using React, where users can input search terms and receive JSON results. I attempted to implement axios cancel token for this functionality, but it doesn't seem to be working properly and I' ...

When both the container and the element have min-height specified in percentages, CSS min-height may not be effective

Check out this simple markup: <div class="fixh"> <div class="outer"> <div class="inner"> inner </div> </div> </div> I am trying to ensure that the inner block has a minimum height ...

The CSS styles are not taking effect as intended

This is my Spring controller @RequestMapping(value = "/board/{id}" ,method=RequestMethod.GET) public String scrumboard(@PathVariable("id") String id) { // if I change string to key error occurs System.out.println(id); //123 return "html/board"; ...

Troubleshooting Typescript app compilation problem in a Docker environment

I am encountering a challenge while trying to build my typescript Express app using Docker. Surprisingly, the build works perfectly fine outside of Docker! Below is the content of my Dockerfile: FROM node:14-slim WORKDIR /app COPY package.json ./ COPY yarn ...

Trouble with linkage in jQuery for AJAX requests in an external .js document

My asp.net application has a master file that includes the jquery.js file. On another page that uses this master page, I have my own jquery code. I attempted to move this code to an external file and then include it in my .aspx file. While most functions ...

The issue with React Hook Form not registering inputs seems to occur specifically when utilizing Material UI's stepper component

Having trouble with a combination of the default Material UI steppers example and React Hook Form. I followed the example found here, but I'm facing an issue where fields registered on the first step are not submitted when the form is submitted on the ...

Applying CSS leads to no visible changes on the screen

I encountered a strange issue with my CSS - the button background color should be blue with white text, but it is not displaying correctly. I tried moving the code within a div container, but it still doesn't work properly. If anyone knows how to solv ...

What methods can I use to verify the expected output in my Jest test?

How can I use Jest to test the return statement? For example, if using Lambda: exports.handler = async (event, context, callback) => { try { const orders = await getOrders(); if (!orders) { console.log("There is no Orders"); ret ...

How can I align Ion-Content to the bottom of the page in Ionic?

I'm having trouble positioning a message input box at the bottom of my page. I've experimented with using align-self-end and creating a css class for ion-footer, but nothing seems to be working. <ion-content> <ion-footer align-self-end&g ...

Creating dynamic web content using PHP and JavaScript

I stumbled upon a tutorial on the PHP.net website within the "PHP and HTML" manual which includes an example titled Generating JavaScript with PHP. Currently, I am experimenting with a basic demo of this concept on my own to grasp the process before attem ...

Resolving a Routing Problem with moment.js

Hi everyone, I'm new to working with express.js and backend routing. I'm encountering an error with my server code and would appreciate any insights on what might be causing it. I've already tried using res.end() with plain text, but the err ...