Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MUI - How do you make a horizontal List?

Tags:

In MUI, I'd like to use:

List and ListItem but have them appear horizontally.

What's the best way?

like image 451
David Avatar asked Mar 03 '16 17:03

David


People also ask

How do I make a horizontal list in material UI?

To make a horizontal list with React Material UI, we can set the style of the List to have the display CSS property set to 'flex' . We call makeStyles with a function that returns an object with the root class. The root class property is set to an object that has the display property set to 'flex' .

How do I make a list appear horizontally?

If you want to make this navigational unordered list horizontal, you have basically two options: Make the list items inline instead of the default block. .li { display: inline; } This will not force breaks after the list items and they will line up horizontally as far as they are able. Float the list items.

How do I make a horizontal list in HTML?

By default, the HTML <ul> list will be rendered vertically with one list item on top of another. When you need to create a list that expands horizontally, you need to add the display:inline style to the <li> elements of the list.


1 Answers

So far I have:

const flexContainer = {   display: 'flex',   flexDirection: 'row',   padding: 0, };  return (   <List style={flexContainer}>     <ListItem       primaryText="foo1"       secondaryText="bar1"/>     <ListItem       primaryText="foo2"       secondaryText="bar2"/>   </List> ); 

This works. Looking for a potential better answer / opinions. Should this be built in?

like image 104
David Avatar answered Sep 28 '22 04:09

David