I want to fix the position of react slick carousel,and want to change the navigation dots style.I am trying in this way....
dots style I want,
Screenshot: https://i.stack.imgur.com/MhOQa.png
`<Show above='md'>
<Box w='50%'>
<Slider {...settings} className='customSlide'>
<Box>
<Image
src={avtar}
/>
</Box>
<Box>
<Image
src={avtar1}
/>
</Box>
<Box>
<Image
src={avtar2}
/>
</Box>
<Box>
<Image
src={avtar3}
/>
</Box>
</Slider>
</Box>
<Divider orientation='vertical' variant={'dashed'} borderColor={'grey'} height='100vh' />
</Show>
`
CSS:
.customSlide{ position: fixed!important; }
Thanks in advance..
I am using material UI version 5.4 and I have a sign-in form and applied validations on it. Validation is appearing properly but my problem is when I placed a long texted error message the exclamation mark is coming below outlined text field of the MUI material.
Here is the screenshot:
And here is the code:
<Box
component="form"
role="form"
sx={{
"& .MuiFormHelperText-root": { color: "#d32f2f" },
"& .MuiInputLabel-formControl": { paddingTop: "5px" },
}}
>
<Box mb={2}>
<TextField
type="email"
label="Email"
variant="standard"
fullWidth
onChange={(e) => emailHandler(e)}
error={emailError}
helperText={emailError ? emailErrorMessage : ""}
/>
</Box>
<Box mb={2}>
<TextField
margin="dense"
type="password"
label="Password"
variant="standard"
fullWidth
onChange={(e) => passwordHandler(e)}
error={passwordError}
helperText={passwordError ? passwordErrorMessage : ""}
/>
</Box>
<Box>
<span style={{ color: "#d32f2f", fontSize: "12px" }}>{error}</span>
</Box>
<Typography variant="button" color="info" to="/forgot-password" component={Link}>
Forgot Password?
</Typography>
<Box mt={4} mb={1}>
<Button variant="gradient" color="newColor" fullWidth onClick={signInHandler}>
sign in
</Button>
</Box>
<Box mt={3} mb={1} textAlign="center">
<Typography variant="button" color="text">
Don't have an account?{" "}
<Typography
onClick={() => {
navigate("/sign-up", { replace: true });
}}
style={{ cursor: "pointer" }}
variant="button"
color="info"
fontWeight="medium"
textGradient
>
Sign Up
</Typography>
</Typography>
</Box>
</Box>
How can I solve this styling issue?
I use chakra ui.
When I hover the sidebar, the sidebar extends to the right.
I am using transition, but the animation is not applied. It is a bit choppy.
I am using transition="all 0.3s" but no animation happens when hover is applied.
I don't know why.If anyone can help me understand, I would appreciate your help.
code
enter link description here
<Flex
background="blue.50"
flexDirection="column"
height="100vh"
justifyContent="space-between"
onMouseEnter={() => setState((prevState) => !prevState)}
onMouseLeave={() => setState((prevState) => !prevState)}
position="fixed"
width={state ? "204px" : "54px"}
zIndex={10}
>
<Box transition="all 0.3s">
<HStack p={3}>
<Flex alignItems="center">
<Image
display={state ? "none" : "inline-block"}
height="24px"
src={""}
transition="all 0.3s ease-in-out"
/>
<Image
display={state ? "inline-block" : "none"}
src={"chakra_logo.png"}
/>
</Flex>
<Text display={state ? "inline-block" : "none"} fontSize="xs">
logo
</Text>
</HStack>
<VStack mt={3} spacing={0}>
<Box _hover={{ backgroundColor: "gray.200" }} width="full">
<Link>
<a>
<HStack p={3}>
<BiSearchAlt />
<Text display={state ? "inline-block" : "none"} fontSize="sm">
search
</Text>
</HStack>
</a>
</Link>
</Box>
<Box _hover={{ backgroundColor: "gray.200" }} width="full">
<Link>
<a>
<HStack p={3}>
<AiOutlineSetting />
<Text display={state ? "inline-block" : "none"} fontSize="sm">
setting
</Text>
</HStack>
</a>
</Link>
</Box>
</VStack>
</Box>
<VStack mb={2} spacing={0}>
<Box mb={2} px={3} width="full">
<Divider borderColor="gray.300" />
</Box>
<Box _hover={{ backgroundColor: "gray.200" }} p={3} width="full">
<HStack>
<Image
alt="MyImage"
src={""}
width="24px"
/>
</HStack>
</Box>
</VStack>
</Flex>
You need to add CSS transition to main Flex also:
<Flex
background="blue.50"
flexDirection="column"
height="100vh"
justifyContent="space-between"
onMouseEnter={() => setState((prevState) => !prevState)}
onMouseLeave={() => setState((prevState) => !prevState)}
position="fixed"
width={state ? "204px" : "54px"}
zIndex={10}
transition={"all .2s ease"}
>...
Is there a way i can make this work? Since flex={1} doesn't do the job?
Or else are there better ways to achieve the same ?
<HStack w='full' spacing={2} bg='yellow.50' align='flex-start'>
<VStack align='flex-start' h='full'>
<Box w={20} h={20} bg='blue.200' class="fixed height element" />
<Box w='20' h='full' bg='green.200' flex={1} class="Fill the remaining height" />
</VStack>
<VStack w='full'>
<Box h={20} w='full' bg='red.100' />
<Box h={20} w='full' bg='red.300' />
<Box h={20} w='full' bg='red.500' />
</VStack>
</HStack>
Not quite sure If I get it right or wrong. The 1st VStack (green section) already fills the remaining space, so your problem is how the 2nd VStack fills the remaining space?
If yes, then the below code should work for you. Provide the height (h="full") to 2nd VStack and the last Box with h="full" will fill the remaining space.
<Grid minH="100vh" p={3}>
<HStack w="full" spacing={2} bg="yellow.50" align="flex-start">
<VStack align="flex-start" h="full">
<Box w={20} h={20} bg="blue.200" class="fixed height element" />
<Box w="20" h="full" bg="green.200" class="Fill the remaining height" />
</VStack>
<VStack w="full" h="full">
<Box h={20} w="full" bg="red.100" />
<Box h={20} w="full" bg="red.300" />
<Box h="full" w="full" bg="red.500" />
</VStack>
</HStack>
</Grid>
USING only flexbox, Box with flexGrow: 1 to occupy all the remaining space
<HStack w="full" minH="100vh" alignItems="stretch" spacing={2} bg="yellow.50" align="flex-start">
<VStack align="flex-start">
<Box w={20} h={20} bg="blue.200" class="fixed height element" />
<Box
w="20"
flexGrow="1"
bg="green.200"
class="Fill the remaining height"
/>
</VStack>
<VStack w="full" h="full">
<Box h={20} w="full" bg="red.100" />
<Box h={20} w="full" bg="red.300" />
<Box h={20} w="full" bg="red.500" />
</VStack>
</HStack>
I'm trying to learn react native.
I have the following code:
<View>
<View style={{flex:0.5,flexDirection="row"}}>
<Image source={{uri:"http://image.com/image1.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 1</Text>
</View>
<View style={{flex:0.5,flexDirection="row"}}>
<Image source={{uri:"http://image.com/image2.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 2</Text>
</View>
<View style={{flex:0.5,flexDirection="row"}}>
<Image source={{uri:"http://image.com/image3.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 3</Text>
</View>
<View style={{flex:0.5,flexDirection="row"}}>
<Image source={{uri:"http://image.com/image4.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 4</Text>
</View>
</View>
But this when I run this code, I get an error saying the line
<View style={{flex:0.5, flexDirection:"row"}}>
"is an unexpected token".
I tried replace 0.5 with 50% and "0.5" but those also causes error.
Basically if this were html css for the web, the behaviour I'm trying to achieve is:
<div>
<div style="width:50%; float:left;">
<img src="http://image.com/image1.jpg" style="width:100%; height:auto;" />
<span>Picture 1</span>
</div>
<div style="width:50%; float:left;">
<img src="http://image.com/image2.jpg" style="width:100%; height:auto;" />
<span>Picture 1</span>
</div>
<div style="width:50%; float:left;">
<img src="http://image.com/image3.jpg" style="width:100%; height:auto;" />
<span>Picture 1</span>
</div>
<div style="width:50%; float:left;">
<img src="http://image.com/image4.jpg" style="width:100%; height:auto;" />
<span>Picture 1</span>
</div>
</div>
In other words, I just want two columns of thumbnail images with a caption underneath each image.
Set up the container with flexDirection:'row' and each child to have half of the screen flexBasis without flex grow. something like this:
<View>
<View style={{flexDirection="row"}}>
<Image source={{uri:"http://image.com/image1.jpg"}} style={{flexBasis:Dimensions.get('window').width / 2, flexGrow:0}} resizeMode={"cover"} />
<Text {{flexBasis:Dimensions.get('window').width / 2, flexGrow:0}}>Picture 1</Text>
</View>
...
I started on react-native not much time ago and I think what you need is something like this:
import React, { Component } from 'react';
import {
StatusBar,
View,
Image,
StyleSheet,
TouchableHighlight
} from 'react-native';
import NavigationBar from './navigationBar';
const logo = require('../../imgs/logo5.png');
const clientMenu = require('../../imgs/menu_cliente.png');
const contactMenu = require('../../imgs/menu_contato.png');
const companyMenu = require('../../imgs/menu_empresa.png');
const serviceMenu = require('../../imgs/menu_servico.png');
export default class MainScene extends Component {
render() {
console.log('Rendering App!');
return (
<View>
<StatusBar
backgroundColor='#CCC'
/>
<NavigationBar />
<View style={styles.logo}>
<Image source={logo} />
</View>
<View style={styles.menu}>
<View style={styles.menuGroup}>
<TouchableHighlight
underlayColor={'#B9C941'}
activeOpacity={0.3}
onPress={() => {
this.props.navigator.push({ id: 'client' });
}}
>
<Image style={styles.imgMenu} source={clientMenu} />
</TouchableHighlight>
<TouchableHighlight
underlayColor={'#61BD8C'}
activeOpacity={0.3}
onPress={() => {
this.props.navigator.push({ id: 'contact' });
}}
>
<Image style={styles.imgMenu} source={contactMenu} />
</TouchableHighlight>
</View>
<View style={styles.menuGroup}>
<TouchableHighlight
underlayColor={'#EC7148'}
activeOpacity={0.3}
onPress={() => {
this.props.navigator.push({ id: 'company' });
}}
>
<Image style={styles.imgMenu} source={companyMenu} />
</TouchableHighlight>
<TouchableHighlight
underlayColor={'#19D1C8'}
activeOpacity={0.3}
onPress={() => {
this.props.navigator.push({ id: 'services' });
}}
>
<Image style={styles.imgMenu} source={serviceMenu} />
</TouchableHighlight>
</View>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
logo: {
marginTop: 30,
alignItems: 'center'
},
menu: {
alignItems: 'center'
},
menuGroup: {
flexDirection: 'row'
},
imgMenu: {
margin: 15
}
});
What you are trying to achieve can be done simply by this code:
<View style={{flexDirection:column}}>
<View style={{flex:1, flexDirection:row}}>
<View style={{flex:0.5,flexDirection:column}}>
<Image source={{uri:"http://image.com/image1.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 1</Text>
</View>
<View style={{flex:0.5,flexDirection:column}}>
<Image source={{uri:"http://image.com/image1.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 1</Text>
</View>
</View>
<View style={{flex:1, flexDirection:row}}>
<View style={{flex:0.5,flexDirection:column}}>
<Image source={{uri:"http://image.com/image1.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 1</Text>
</View>
<View style={{flex:0.5,flexDirection:column}}>
<Image source={{uri:"http://image.com/image1.jpg"}} style={{width:100,height:'auto'}} resizeMode={"cover"} />
<Text>Picture 1</Text>
</View>
</View>
</View>
You have to give style={{flex:1}} to the main view and this might solve your problem.
MdBalal's strategy will not work. flex:0.5 in RN is not the same as in web standard, it will not work if
you put more than 2 children components in container. A walk-around is group children to two components in one container. Eg:
Suppose we have 3 child components in Container,
**Before**:
<Container><Child/><Child/><Child/></Container>
**After**:
<Container><Child/><Child/></Container> and
<Container><Child/><EmptyPlaceholder/></Container>