How can I set the width of Dialog in Material UI based on the changing content? - reactjs

I am creating a dialog with MUI which contains three types of content whose width is very different.
First, I need to upload an image and in the second content I need to crop it and third I have to be able to add a caption for it. So how do I set the width for the dialog such that even if images of varied dimensions are chosen it is completely shown?

For that dialog, add sx = {{ width:'fitContent' }} and try if that works

Related

Change span label font size in codenameone

I want to show a multiline text so I use a span label. I am trying to set the font size from the gui but it does not change.
I also trying to set the color dynamicaly using the next code:
this.gui_Span_Info.getAllStyles().setFgColor(HTMLElement.COLOR_RED);
but nothing happens.
What should I do?
SpanLabel is a composite component which means it's built from 2 or more separate components one of which is a Container.
You can determine the UIID of the text using setTextUIID it defaults to the Label UIID.

Apply style regardless of content length of button

I have 2 buttons. say for example a "Browse" button and a "Start Data Backup" Button. I have applied a common style to these buttons. find the buttons below.
As you can see, the content of the browse button aligned properly to the center. But the another one doesn't have any borders. it occupied the button completely. I know it is due to the length of the text and we can fix it by setting the width of the button, but unfortunately i cannot set my button width .because i need my button should give same look with different screen resolution.
What i need now is, the content should be aligned as like in browse button regardless of content length. How to achieve this?
If you have limitation on changing the width of Button for different screen resolutions, instead of changing the width of button try overwriting the font size of the content in button. Also make use of content wrapping to get extra text in new line.

How to resize material-ui's tabs

I am trying to get a result looking like this (picture taken from https://material.google.com/components/tabs.html#tabs-usage):
I don't want the tabs to take 100% of the width of the page, as it is by default with material-ui. Is it possible to do this with the implementation of material-ui ? I already played with the width of each tab using the style tab property, but the inkbare seems hardcoded to use percentages according to the id of the selected tab, and therefore doesn't underline properly the resized tabs. Is there a workaround?
There is an issue related to this problem https://github.com/callemall/material-ui/issues/1203
But yes, there is an easy workaround. (unfortunately it doesnt support diffrent widths across the tabs).
You can use the Tabs tabItemContainerStyle property to set the width of the tabs container (make it the width you want to each tab times the number of tabs).
Since the background color is setted on that element, you're gonna need to override the styles for two others Tabs properties (style and contentContainerStyle).
In this example Im setting the same color as my tabs in the style property (for the whole component) and setting the contentContainerStyle back to a white background.
You could use the classes properties as well..
Ex: (Imagine you have a blue toolbar)
<Tabs
tabItemContainerStyle={{width: '400px'}}
style={{background: 'blue'}}
contentContainerStyle={{background: '#FFF'}} >

How can I reduce the padding on a Dialog?

When I press a button, my app displays a calendar (within a Dialog) that slides from the bottom of the screen:
I want the Calendar to occupy the whole width of the screen, but it shows some white padding on both sides and also on the top and bottom (It is white because the "Dialog" UIID has a white created image as background)
I have tried changing all the UIID related to Dialog: "Dialog", "DialogBody", "DialogTitle", etc. I set all margins and paddings to cero.
How can I get rid of that padding?
Try change both the DialogUIID and the UIID of the dialog. Also make sure your calendars margin values are set to zero. It could be that your calendar is too small. Try placing it in a table layout with 1 row and 1 column then in layout constraints set the width and height to 100%
Open up the Component Inspector tool and traverse the hierarchy. You will be able to see all the components and their UIID's within the hierarchy and you should be able to understand which one of those components contributes to the padding/margin.

Images for command buttons in footer facet

I currently have two command buttons in the footer / header facets - I am trying to have images in those buttons.
Using property inspector I am able to add images for these buttons - but they show up very tiny - no matter whatever the size of image.
Is there a way I can adjust the size of this image display in the property inspector or any where else please?
Did you consider styling the Command Buttons or Use Image Link instead

Resources