I use button in react-native-paper with icon. I need to add a shadow style only to the icon of the button. The only available option I found was to add an elevation to the button. But it is applied to the whole button instead of applying only to the icon of the button.
The code of button:
<Button
icon={icon}
onPress={onPress}
size={size}
color={color}
animated={animated}
disabled={disabled}
style={styles.btnStyles}
/>
The Style of button to add shadow:
btnStyles: {
elevation: 40,
shadowColor: '#000',
backgroundColor: 'rgba(0,0,0,0)',
},
The result:
enter image description here
(Here you can see that the shadow is applied to the button, not to the icon inside.)
How can I solve above issue and add a shadow only to the icon?
Thanks in advance.
Related
If there is required then show TextField border color is red and once entered value then show NO RED border.
Please click on the link to see images.
Entered Value
Without Value with Required field
You can put a condition on the TextFields error like this
<TextField variant="outlined" label="Amount" name="amount' helperText={touched.amount ? errors.amount : ''} error={touched.amount && Boolean(errors.amount)} fullWidth />
I have a Material UI Slider in my application. I want to keep a thumb invisible until the user changes the slider value. When the slider is used, I want a thumb to stay visible at the value that users sets. Using the active CSS property, I managed to hide the thumb and show it only while the user uses it, which is while the slider is dragged by finger or mouse pointer. When the interaction stops, I want it to stay at the chosen value, but it disappears.
Initial state
Slider is interaced with (dragged)
Finished interaction
I tried adding another, duplicated slider, with thumb component visible all the time and then tried to conditionally render one of the sliders depending on the value (value ? <Slider1 /> : <Slider2 />), but it worked to some extent. Thumb was always set to the beggining of slider, independently from the value.
Any ideas? Thanks.
For code samples, refer to material ui slider API.
Maybe using withStyles(), import withStyles and the Slider:
import { withStyles } from "#material-ui/core/styles";
import Slider from "#material-ui/core/Slider";
then customize your Slider, something like this:
export const CustomizedSlider = withStyles({
thumb: {
height: 28,
width: 28,
backgroundColor: "transparent",
marginTop: -14,
marginLeft: -14,
"&:hover, &$active": {
backgroundColor: "red",
},
},
})(Slider);
The default color should be "transparent" and It will change to "red" when the mouse hovers it. More about withStyles() here. Hope this helps you!.
code reference: https://github.com/mui-org/material-ui/blob/master/docs/src/pages/components/slider/CustomizedSlider.js
I have the following code with me. Please help me how to add opacity or how to dim the background while modal is open.
Here is the working example
Add this backgroundColor property to your Modal component in line 57:
style={{
display: this.state.display,
backgroundColor: this.state.modalShow ? "red" : "none"
}}
What this does is that when the modalShow state is truthy (aka when it's shown) the backgroundColor returns red and none the other way. To dim it you can use rgba(0,0,0,.2) instead of red obviously
EDIT: sandbox
How can I edit the animation of the dropdown in Materialize.css Framework?
https://materializecss.com/dropdown.html
css code of dropdown-content by Materialize.css
There are inline translateY and X that are animating inline when I click. How can I make it appear from the top?
I need to create a hover for the navigation as this example
https://codepen.io/AUDesign/pen/VNYYrV
This doesn't help..
$('.dropdown-trigger').dropdown({
constrainWidth: false,
coverTrigger: false,
hover: true,
inDuration: 300,
outDuration: 300,
alignment: 'left', // Displays dropdown with edge aligned to the left of button
});
Go to https://snack.expo.io/HJV601djf and open login_screen/components/Form.js. As you can see, the textInput has the style
textInput: {
flex:1,
height: 50,
marginBottom: 20
}
You can see that the user icons are not aligned with the text input. If I take marginBottom out, everything goes ok, but with marginBottom: 20 the icons get dealigned. I can probably fix that by making the text input get aligned vertically too, but I'll not know the cause of the problem.
How can marginBottom affect the insides of UserInput if it's supposed to add space only on the outside?
Printscreen if you don't want to wait to load the app:
This is happening because , in your UserInput.js, you are trying to merge the styles for the textInput while the Image / Icon styles are remaining the same, therefore it is misaligned.
The optimum way to solve this would be to add a textInputContainer style to the component and set the margin to it as
TextInput.js
<View style={mergeObjects(this.props.containerStyle ? StyleSheet.flatten(this.props.containerStyle) : {}, StyleSheet.flatten(styles.inputWrapper))}>
Form.js
<UserInput
containerStyle={styles.textInputContainer}
style={styles.textInput}
source={{uri:'http://www.free-icons-download.net/images/user-icon-74490.png'}}
placeholder="e-mail"
autoCapitalize={'none'}
returnKeyType={'done'}
autoCorrect={false}
/>
and the styles
textInputContainer : {
marginBottom: 20
},
Here's the snack for the same