Experiencing difficulty aligning the Material UI grid to float on the right side

I'm currently in the learning phase of material-ui and encountering an issue with floating the grid content to the right side.

Despite trying

alignItems="flex-start" justify="flex-end" direction="row"
in the container grid, as well as using the css property float:right, I have not been successful.

I've explored a response on stackoverflow from this question, but it didn't resolve my problem.

Below is my code and you can also access it on codesandbox through this link

import React from "react";
import ReactDOM from "react-dom";
import {
  ExpansionPanel,
  ExpansionPanelSummary,
  ExpansionPanelDetails,
  Typography,
  Grid
} from "@material-ui/core/";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";

function App() {
  return (
    <ExpansionPanel square defaultExpanded={true}>
      <ExpansionPanelSummary
        style={{ backgroundColor: "#009ACD", color: "white" }}
        expandIcon={<ExpandMoreIcon />}
        id="panel1a-header"
      >
        <Typography variant="h6">General Details</Typography>
      </ExpansionPanelSummary>
      <ExpansionPanelDetails>
        <Grid container>
          <Grid item sm={3}>
            Image Container
          </Grid>
          <Grid item sm={2}>
            <Typography variant="h6"> {"Prabhat Kumar"}</Typography>
            <Typography> Tester </Typography>
          </Grid>
          <Grid
            contaienr
            sm={7}
            alignItems="flex-end"
            justify="flex-end"
            direction="row"
          >
            <Grid item>
              <Typography variant="h6">
                      Need this content on the right side
              </Typography>
            </Grid>
          </Grid>
        </Grid>
      </ExpansionPanelDetails>
    </ExpansionPanel>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Answer №1

While experimenting with your sandbox, I noticed a couple of things that needed attention:

contaienr should be corrected to container

         <Grid
            contaienr // Fix
            sm={7}
            alignItems="flex-end" // remove
            justify="flex-end"
            direction="row" // Remove
          >

To resolve this issue, simply replace the code snippet with the following:

<Grid container sm={7} justify="flex-end">

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

Is it possible to display a Processing message at the beginning of a datatables table already containing data?

Within my Laravel 5.7 application, I have implemented the "yajra/laravel-datatables-oracle": "~8.0" library and found a helpful thread on customizing the processing message at this link. I adjusted the processing message styling as follows: .dataTables_pr ...

Is there a way to accurately retrieve the width of an element within setInterval without any delay?

I'm currently experimenting with increasing a progress bar using the setInterval function. So far, it seems to be functioning properly. var progressBar = $('.progress-bar'); var count = 0; var interval = setInterval(function () { va ...

UI experiencing issues with selecting radio buttons

When trying to select a radio button, I am facing an issue where they are not appearing on the UI. Although the buttons can be clicked, triggering a function on click, the selected option is not displayed visually. <div data-ng-repeat="flagInfo in avai ...

Encountered an issue when attempting to utilize `npm start` within a React JS project following

https://i.stack.imgur.com/yII3C.png Whenever I attempt to run npm start in the vsCode terminal, an error pops up as shown in the image above. In the picture provided, you can see that my package.json only contains a start script. Can anyone offer assistan ...

Tips for troubleshooting getStaticProps (and getStaticPaths) in Next.js

Currently, I am attempting to troubleshoot the getStaticProps() function within a React component that is being utilized from my pages by implementing console.log() like so: export default class Nav extends React.Component { render() { return & ...

Hover over the first element to remove its class and replace it with a different element

I am attempting to develop a function that adds the class = "actived" to the first Element. This class has a CSS style that highlights the element in question. I have a list of 4 lines and I want the first one to automatically receive this class, while t ...

Search bar placeholder text appears off-center in Firefox browser

I have implemented a universal search bar on our website and it is working perfectly in Chrome and Safari. However, I am facing an issue with Firefox where the placeholder text is aligned to the bottom of the bar instead of the middle. Usually, placeholder ...

What is the best way to utilize the history prop in conjunction with other props?

I am currently using react-router-dom along with react. My goal is to include additional props along with the history prop import React from 'react'; function MyComponent({ history }) { function redirect() { history.push('/path&ap ...

The columns in the table are all displaying varying widths even though they have been defined with fixed table layout

I have a nested table displayed in my HTML, and I am attempting to set each column to be 50% width, but for some reason it's not working. In the past, whenever I've needed to accomplish this, applying table-layout: fixed has usually done the tri ...

Is there a way to include a tag as an argument in a scss mixin?

Currently, I am working on a mixin that will target a specific child element within a parent. For instance, my goal is to target all <a> tags within a parent element that also has a parent of section---blue. I initially thought that passing the tag ...

Is there a way to switch the classList between various buttons using a single JavaScript function?

I'm currently developing a straightforward add to cart container that also has the ability to toggle between different product sizes. However, I am facing difficulties in achieving this functionality without having to create separate functions for ea ...

What is the proper method to restrict a function to execute exclusively on the frontend following authentication on the backend?

My React frontend currently features two buttons—one for authentication and the other for displaying data once authenticated. frontend: const auth = async () => { window.open("callbackApiRouteOnBackend") } const displayData = async () ...

Utilizing React's useState to store data in local storage

I am trying to figure out how to save data from a photos database API into local storage using the useState hook in React. Despite my attempts, I have not been successful with the useState method as the data in local storage gets cleared upon page refres ...

Encountering 408 timeout error when sending post requests in a MERN application

My form is designed to transfer user input data to my MongoDB cluster: // Registration.jsx import React, { useState } from 'react'; import axios from 'axios'; const Registration = () => { const [email, setEmail] = useState('& ...

I keep encountering an error that says "ReferenceError: localStorage is not defined" even though I have already included the "use

I have a unique app/components/organisms/Cookies.tsx modal window component that I integrate into my app/page.tsx. Despite including the 'use client' directive at the beginning of the component, I consistently encounter this error: ReferenceErr ...

Best practice for executing two .save() operations in mongoose

I've been attempting to save to two different documents and models within the same function, but I keep encountering strange errors no matter what approach I take. It appears that for some reason, mongoose is not allowing this to work as intended. Cu ...

Is it possible to pass a prop component to mui styled function()?

Can I pass a component prop to the MUI styled utility? I want to transfer an icon component from parent to child and then use this icon in a styled component within the child. Parent: export const ButtonWithIcon = Template.bind({}); ButtonWithIcon.args = ...

Troubleshooting JavaScript for Sidebar Disappearance due to marginRight and display CSS Issue

I need to adjust the layout of my website so that the sidebar disappears when the window is resized below a certain width, and then reappears when the window is expanded. Here is the HTML code: <style type="text/css"> #sidebar{ width:290 ...

Undefined React custom hooks can be a tricky issue to troub

Just delving into the world of React and trying to wrap my head around custom hooks, but I keep hitting roadblocks. Here's the latest hurdle that I'm facing, hoping for some guidance. I'm taking a step-by-step approach to creating a functio ...

Changing the Values of Variables in an npm Package within SvelteKit

I have been working on a SvelteKit component library where I define variables for components like background-color and font-family in a CSS file. Inside the ./dist/index.js file of my library, I export the CSS using `import './main.css'`. When in ...