How to use Material UI Grid spacing prop properly in nested grids? - reactjs

I am trying to create a Basic Layout with React using Material UI Grid component.
I am following official documentation but the spacing prop seems very confusing and there is very less information available or its unclear in documentation.
When i am trying to nest Grid to create the layout, the negative margins added by the spacing prop confusingly pulling the items and breaking the UI.
Below is the very simple Layout in trying to do
I finally managed to do it with some very complex nestings and custom styles using sx prop as shown below in the codesandbox.
https://codesandbox.io/s/materialgriddilemma-vheq19?file=/src/Layout.js
But I am wondering, for a simple use case as this do I really need to write custom styles?!!
What is the cleanest and recommended way to use Nested Grids in Material UI with Spacing ?

Related

React Dropdown dynamic buttons with material UI

I am trying to copy the parts inside black circles on the image below for training React and Material UI. My problem is that I am struggling a bit with which Material UI components to use... Any help or examples that looks like this are happily accepted!
There are some components from material-ui for composing the UI like what you asked for. You need to compose these components by yourself.
For components inside the long black circle, they can be from selects https://mui.com/components/selects/. You can find different styles from this link.
For components inside another circle. They are buttons, text_fields, chips, and cards. Which can be found from
https://mui.com/components/buttons/ https://mui.com/components/text-fields/ https://mui.com/components/chips/ https://mui.com/components/cards/
Can't give an answer for the part of Minerva Obj Name without knowing how it is interacted.

How to snap Draggable's to Grid? (Material UI)

I am trying to make a card that is draggable, which is layered on top of a grid, and when moved, I want it to snap to the different sections of the Grid. I am able to create the grid with the columns and rows and also a draggable item, but I am not sure as to whether the snap to grid is possible with Material UI. Is there a way to do this by using Material UI and ReactJS?
If not possible with Material UI, is there another dependency I can use to achieve this?
I have used many drag and drop libraries but love this one most. You can give it a try.
There is a story book demo at https://bokuweb.github.io/react-rnd/stories/?path=/story/grid--both. I think that perfectly resolve your problem.
react-dnd is compatible with Material UI and lets you create a drag layer and snap to a grid.
See react-dnd's basic demo here
And here is how you can extend it to things like: snapping, grid constraints, render arbitrary child components, reordering children

React Semantic UI Font

I start to use the React Semantic UI library, but it's not so easy to customize elements.
I have a basic HTML header in y component that I want to set the Font to "Rubik"
So in my src/semantic-UI/site/globals/site.variables i added this line
#headerFont 'Rubik', I am not sure if it's the good way to do that, also I would to also edit the font-size, line-height, and font-weight?

Material UI Stepper with alternative label placement

I want to create a material-ui stepper element which looks like this:
They call it stepper element with alternative label placement.
I am using material-ui library which implements Google's Material Design. Right now all examples from that library show in-line label placing and I don't see any property which would make it possible to use alternative label placement. But I believe it was implemented at some point of time because there was discussion about it.
Is there a way to set alternative label placement for stepper right now?
According to their docs Labels can be placed below the step icon by setting the alternativeLabel prop on the Stepper component.

Bootstrap DropdownButton Styling

I have the following code:
header_contents.push(<DropdownButton bsSize='xsmall' bsStyle='link' pullRight={true} id={1} title='Menu'>
{item_menu}
</DropdownButton>);
I want to have the styling in Bootstrap to be white lettering (currently blue) as I think the link option is defaulted to that. How can you change the styling for Bootstrap to pass link color, and other properties like if you want to move the link down a little on the page?
I should mention we do very little CSS styling as most of that is done within the ReactJS components.
Either override bootstrap CSS in a css file (that is what your seem to avoid I understand): it is the better way to ensure a global effect over every link in your application.
Or do no sent bsStyle='link' as DropdownButton property but instead, insert a style property with custom CSS. Yet you can insert style even if you don't remove bsStyle. You could then create your own component wrapping DropdownButton to ensure the same graphic chart in your application.
I figured it out with the help of an online chat room. Here's what I did.
I first made a style (dropDownLinkStyle) in the react component like this.
let dropDownLinkStyle = {
color: 'white'
};
Then I used it (dropDownLinkStyle) in the dropdownButton like this.
header_contents.push(<DropdownButton bsSize='large' style={dropDownLinkStyle} bsStyle='link' pullRight={true} id={1 /* avoids react warning */} title='Menu'>
{item_menu}
</DropdownButton>);
I hope this helps. This allowed me to keep my bsStyle which is link (tells Bootstrap I want a link type on my screen instead of a button) and allows me to change that link to white lettering. I could also pass more styling by just adding it to the object -- dropDownLinkStyle

Resources