How to know if material-ui TextField was truncated - reactjs

I have given a custom styling to my TextField mui component like below:
'& > * .MuiFilledInput-input': {
overflow: 'hidden',
textOverflow: 'ellipsis',
},
This is to show the ellipsis when the text is truncated inside TextField. This works fine but now I need to show a tooltip only when the text is truncated. So somehow I need to find out if the TextField used above styling or if the text was truncated. I do not want to use hard-coded length/width approach but instead find it out dynamically. Any ideas how to do it?

Related

How to limit the height of MUI Autocomplete input box

I am having trouble in limiting the height of MUI Autocomplete component. When I select the value from the list it automatically add empty space or row at the bottom of input which I do not want.
Below is my example.
https://codesandbox.io/s/mui-5-forked-n8nc6i?file=/src/App.js
screenshot
If you want to bypass the default css style from MUI, then you can use inside your css the following:
.MuiAutocomplete-inputRoot {
flex-wrap: nowrap !important;
}
example

Hide component that renders a Tabs

I have a component that renders Tabs component from Material UI 5.0.0-beta.5
There is a case when I set this components display to none.
But, then I get this error -
Material-UI: The value provided to the Tabs component is invalid. The Tab with this value (0) is not part of the document layout. Make sure the tab item is present in the document or that it's not display none.
I understand the error, and I am setting its display to none because but I wanna show and hide the component without re-rendering (because I want the user selections to persist).
Is there a way to fix this error or maybe a better way to do what I am trying to do?
You could try to use visibility: hidden instead
And if you want not to take up the space to the hidden component, set its width and height to 0 and then change them later to show the UI.
visibility: hidden;
width: 0;
height: 0;
And when you want to show it back:
visibility: visible;
width: 100%;
height: 100%;

React Native Navigation Styling Issues

I am using React Native Navigation top tabs. I am having a issue with the text getting cut or wrap. Is there any way that I can style where all the tab names show correctly without text wrap
Set a width to the tabbar, like this
tabBarOptions: {
tabStyle: {
width: 'auto' //or put some other width which works for you
}}
Also consider using scrollable tabs or reducing font size.

Antd: I'm trying to change the default styling of Antd's checkboxes using styled components to make the checkbox larger and change the color to black

I have an Antd checkbox that I'm trying to make larger, alter the thickness of the box itself and change the color to black but every style I apply creates a second square that sits over the checkbox and doesn't change the checkbox itself. Does anyone have any ideas on how to do this?
Figured this out by using &&&{border: 2px solid ${({ theme }) => theme.colors.black} the triple ampersand allows you to add more specificity when working with mixed styled components like mine.

React-bootstrap Component Font Size

I wanted to manually changed the font size for a ReactJS project. I tried to add something like
* {
font-size: 10px;
}
and that works with everything that is a plain text. However, every component from react-bootstrap (e.g., DropdownButton, Panel) remains a large font size. Thus, what is the correct way to change the font size for those react-bootstrap components to the same as for other plain text? Inline styling works but I would like the changes to apply to a .css file. Thanks!
Edit: Panel Header code snippet:
<Panel>
<Panel.Heading>
<Panel.Title>
title here
</Panel.Title>
</Panel.Heading>
...
To change the font-size of all text in your project, use
* {font-size: 10px;}
Alternatively, you can pass a style prop to a component, EX: <Panel.Body style={{fontSize: 10}}
It's simple you can add style={{fontSize:"10px"}} inside the jsx button or any element, this will directly apply to your jsx element and bootstrap default won't work.

Resources