How to horizontally align Material-UI elements in ReactJS

My goal is to create a user-friendly form where respondents can input answers to questions and select one as the preferred option by using a radio button. However, I'm facing an issue where Material-UI displays each element on its own line.

This is the current code snippet being used:

<div>
   <RadioButton
      value="light"
   />
   <TextInput
       hintText="Answer"
       multiLine = {true}
   />
</div>

Answer №1

Just wanted to share that I successfully organized radio buttons using the flexboxgrid framework... Here's a snippet of how I achieved it:


      <div className="row">
        <div className="col-md-2">
          Type:
        </div>
        <div className="col-md-10">
          <RadioButtonGroup
             className="row"
             name="type">
            <RadioButton
               className="col-md-4"
               value="other"
               label="Other" />
            <RadioButton
               className="col-md-4"
               value="custom"
               label="Custom" />
          </RadioButtonGroup>
        </div>
      </div>

Answer №2

Utilizing the react-inline-grid library in conjunction with material-ui has greatly enhanced my layout experience, addressing various challenges and promoting a more deliberate approach to code organization (not to mention its responsiveness).

<Grid>
  <Row is="nospace start">
    <Cell is="9 tablet-6 phone-3">
       <TextField ... />
    </Cell>
    <Cell is="middle 3 tablet-2 phone-1">
       <RaisedButton ... />
    </Cell>
  </Row>
</Grid>

Answer №3

Utilize the style object in Material-Ui to customize the default styles of the element. One example is setting the display property to inline-block.

display: inline-block;

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

I wish to adjust the font size as well as resize the table elements simultaneously

Adjusting the height and width of the table should automatically adjust the font size as well. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Resizable - Default functiona ...

Secret button concealed within a div, revealing only a helpful hint

On my website, there is a list of items where each item is represented by either a picture or a name enclosed in an <article> tag. Here is an example of how it looks: <article class="client-card"> <p><img width="211" height="106" ...

Can the typical drag and drop cursors be ignored in an HTML drag operation?

I've been working with the HTML drag and drop API to allow users to resize columns in a table. However, I've noticed that when a user starts dragging a column, the cursor changes to one of the default drag and drop effects (such as move or none). ...

Fluid Grid System with columns of specific dimensions

Recently delving into the world of Foundation Framework, I've just begun utilizing it for my projects. My current task involves crafting a responsive design with the help of the Foundation Grid system. Specifically, I've set up a grid layout for ...

When attempting to run npm start, an error message appears indicating a failed compilation due to the inability to resolve

Error compiling ./node_modules/jest-serializer/build/index.js Module not located: Unable to find 'v8' in 'C:\Users\Desktop\reactapp\react-project\node_modules\jest-serializer\build' This issue arose du ...

Having problems with Javascript and CSS not playing well together?

I have implemented a button from this source, but it does not appear correctly on my page. You can view the screenshot here. It seems like there is a conflict between the saved changes and the CSS. How can I resolve this issue? In addition, I am facing ...

Can you define the "tab location" in an HTML document using React?

Consider this component I have: https://i.stack.imgur.com/rAeHZ.png React.createClass({ getInitialState: function() { return {pg: 0}; }, nextPage: function(){ this.setState({ pg: this.state.pg+1} ) }, rend ...

Verify if the username or phone number is already in use (front end)

Is there a way to verify user or phone existence on the front-end form? I'm using Yup + Formik for all my requirements, and in my backend with Sequelize, I can check if a username or phone number already exists. passport.use( 'register&apos ...

Discovering the dimensions of a disabled attribute within a table using XPath in Selenium with Java

I'm attempting to determine the number of columns in a specific table, but some are disabled - I'd like to know if it's possible to get the count without including the disabled ones (only counting the visible columns). As you can see in the ...

Responsive design with Flexbox, interactive graphics using canvas, and dynamic content resizing

I'm having difficulties with my canvas-based application. I have multiple canvases, each wrapped in a div container alongside other content. These containers are then wrapped in an "hbox" container. The objective is to create a dynamic grid of canvas ...

What is the method to set up Material-UI Docs without the need to install material-ui library

Currently, the process to install and run material-ui docs locally involves two separate npm install commands - one within material-ui directory, and another within material-ui/docs directory. You may want to use the docs site as a starting point for your ...

What is the best way to replicate touch functionality on mobile browsers for both Android and iPhone devices?

Recently, while developing a web application, I ran into an issue on mobile browsers where the :active pseudo class wasn't functioning properly. I am currently utilizing CSS sprites and looking for guidance on how to simulate clicks for mobile browser ...

Encountering a 400 status error while trying to fetch data using React Hook Form

My custom book search application allows users to input a query, which then displays the response data. After following the example for schema validation from the React Hook Form documentation, I encountered an Error: Request failed with status code 400. ...

I am having trouble getting the exit animation to work in Framer Animation, despite using AnimatePresence, motion.div, and a unique key

Hello and thank you for taking the time to read this! :D I'm currently facing an issue with getting Framer Motion to work properly. My code seems to be functioning well for all features except for the exit animation. I have assigned a unique key as w ...

Using the max-width property with Semantic UI Dropdown in ReactJS

I'm struggling to determine how to adjust the max-width of the Dropdown element in ReactJS. I attempted the following: .Menu Dropdown { max-width: 5rem !important; } Unfortunately, this did not work as expected. The dropdowns are taking up too m ...

What is the best way to pass the value of a button to a different react component

Hey there! I'm currently working on a form component that includes a button array. I've added icons to the buttons using the value attribute, like so: <button value={'admin'} onClick={(e)=> handleClick(e.target.value)}> & ...

a single column with a div of varying height using flexbox

I need to create a div with a height of 120px using only the CSS property display: flex. I am not allowed to use float and can only use div elements. Here is the code I have so far, but I'm unsure how to achieve the desired outcome: .flex-containe ...

Define two categories within the Attributes interface

To avoid theme-ui errors in the sx prop, I need to declare both of these statements: declare module "react" { interface Attributes { sx?: ThemeUIStyleObject; } } and declare module "react" { interface Attributes { sx?: Sx ...

Is it possible to make consecutive axios requests?

I have a ReactJs application with two functions: AuthService.addUser(newUser); AuthService.userCategories(usercategories); When the submit button is clicked, I want to run these functions separately. The Axios request of the second function should be ca ...

Checkbox: Customize the appearance of the root element

I am trying to modify the root styles of a Checkbox component, but it is not working as expected. Here is my code: <CheckboxItem onChange={()} checked={isChecked} label="Show Checkb ...