Content-Length: 620171 | pFad | https://docs.nativebase.io/migration/utility-props#h3-color-and-background-color
Playgroundconst NBBox = props => {return <Box borderRadius="md" bg="primary.600" {...props} />;};function Component() {return <>{/* m="2" refers to the value of `theme.space[2]` */}<NBBox m="2" p="5" />{/* You can also use custom values */}<NBBox mx="auto" px="20" py="5" />{/* sets margin `8px` on all viewports and `16px` from the first breakpoint and up */}<NBBox m={[2, 3]} pt="10" pr="10" /></>;}function Example() {return <NativeBaseProvider><Center flex={1}><Component /></Center></NativeBaseProvider>;}
Playgroundfunction NBBox(props) {return <Box p="5" m="2" borderRadius="md" bg="primary.200" {...props} />;}function Component() {return <>{/* raw CSS color value */}<NBBox bg="#10b981" />{/* picks up a nested color value using dot notation */}{/* => `theme.colors.lightBlue[300]` */}<NBBox bgColor="cyan.100" py="3">{/* using theme colors to set text color */}<Text color="cyan.500" fontWeight="bold">{" "}I love NativeBase</Text></NBBox>{/* verbose prop */}<NBBox backgroundColor="#eab308" /></>;}function Example() {return <NativeBaseProvider><Center flex={1}><Component /></Center></NativeBaseProvider>;}
Playgroundfunction App() {return <Stack space="2" alignItems="center"><HStack space="2" alignItems="center"><Center size="16" bg="primary.400:alpha.30" rounded="md" _text={{color: "white"}}>Box 1</Center><Center size="16" bg="primary.400:alpha.70" rounded="md" _text={{color: "white"}}>Box 2</Center><Center bg="primary.400" size="16" rounded="md" _text={{color: "white"}} shadow="1">Box 3</Center></HStack></Stack>;}function Example() {return <NativeBaseProvider><Center flex={1}><App /></Center></NativeBaseProvider>;}
Playgroundconst NBText = props => {return <Text m="2" {...props} />;};function Component() {return <>{/* font-size of `theme.fontSizes.2xl` */}<NBText fontSize="2xl" fontWeight="bold">Thank You{" "}</NBText>{/* text decoration `underline` */}<NBText textDecoration="underline">Merci Beaucoup</NBText>{/* font-size `'2em'` */}{/* font-weight of `theme.fontWeights.semibold i.e. 600` */}<NBText fontWeight="bold">Danke sehr </NBText>{/* letter-spacing `0.1 em` */}<NBText letterSpacing="2xl">Arigatou </NBText></>;}function Example() {return <Center flex={1}><Component /></Center>;}
Playgroundconst NBBox = props => {return <Box m="2" borderRadius="md" bg="primary.600" {...props} />;};function Component() {return <>{/* verbose */}<NBBox width="100%" height="8" />{/* shorthand */}<NBBox w="100%" h="32px" />{/* use boxSizing */}<NBBox boxSize="12" />{/* width `50%` */}<NBBox w="50%" h="8" />{/* width `256px` h="8" */}<NBBox w="256" />{/* width `"40px"` */}<NBBox w="40px" h="8" /></>;}function Example() {return <NativeBaseProvider><Center flex={1}><Component /></Center></NativeBaseProvider>;}
Playgroundconst NBBox = props => {return <Box p="5" m="2" borderRadius="md" bg="primary.600" {...props} />;};function Component() {return <>{/* verbose */}<Box display="flex" flexDirection="row" justifyContent="space-between"><NBBox /><NBBox /><NBBox /></Box>{/* shorthand using the `Flex` component */}<Flex align="center" justify="center"><NBBox /><NBBox /></Flex></>;}function Example() {return <NativeBaseProvider><Center flex={1}><Component /></Center></NativeBaseProvider>;}
Playgroundconst NBBox = props => {return <Box p="5" m="2" borderRadius="md" bg="primary.200" {...props} />;};function Component() {return <><NBBox borderWidth="1" borderColor="cyan.500" /><NBBox borderWidth="2" borderColor="cyan.500" /><NBBox borderColor="cyan.500" borderTopWidth="7" /></>;}function Example() {return <NativeBaseProvider><Center flex={1}><Component /></Center></NativeBaseProvider>;}
Playgroundconst NBBox = props => {return <Box p="5" m="2" bg="primary.500" {...props} />;};function Component() {return <>{/* picks up a nested radius value using dot notation */}{/* => `theme.radius.md` */}<NBBox borderRadius="md" /><NBBox borderRadius="full" />{/* partial border radius */}<NBBox borderLeftRadius="10" />{/* absolute value prop */}<NBBox borderRadius="8" /></>;}function Example() {return <NativeBaseProvider><Center flex={1}><Component /></Center></NativeBaseProvider>;}
Playgroundconst NBBox = props => {return <Box p="5" borderRadius="md" bg="primary.400" {...props} />;};function Component() {return <Box justifyContent="center" alignItems="center" flexDirection="row"><NBBox position="relative" p="7" /><NBBox bg="yellow.400" zIndex={2} position="absolute" /><NBBox bg="emerald.400" position="relative" p="7" /></Box>;}function Example() {return <NativeBaseProvider><Center flex={1}><Component /></Center></NativeBaseProvider>;}
Playgroundconst NBBox = props => {return <Box p="5" m="2" borderRadius="md" bg="primary.500" {...props} />;};function Component() {return <>{/* => `theme.shadows.md` */}<NBBox shadow="1" /><NBBox shadow="3" /><NBBox shadow="5" /><NBBox shadow="7" /><NBBox shadow="9" /></>;}function Example() {return <NativeBaseProvider><Center flex={1}><Component /></Center></NativeBaseProvider>;}
Playgroundfunction App() {return <Button _text={{// below props will will let you style the text of the buttoncolor: "primary.100",fontSize: "md",fontWeight: "bold",underline: true}}>Save</Button>;}function Example() {return <NativeBaseProvider><Center flex={1}><App /></Center></NativeBaseProvider>;}
Playgroundfunction App() {return <Button colorScheme="yellow" _pressed={{// below props will only be applied on button is pressedbg: "yellow.600",_text: {color: "warmGray.50"}}}>Save</Button>;}function Example() {return <NativeBaseProvider><Center flex={1}><App /></Center></NativeBaseProvider>;}
Playgroundfunction App() {return <Button _web={{// below props will only be applied on 'web' platformbg: "yellow.400",_text: {color: "coolGray.800",fontWeight: "medium"},_pressed: {// below props will only be applied on button is pressedbg: "yellow.600",_text: {color: "warmGray.50"}}}}>Save</Button>;}function Example() {return <NativeBaseProvider><Center flex={1}><App /></Center></NativeBaseProvider>;}
Fetched URL: https://docs.nativebase.io/migration/utility-props#h3-color-and-background-color
Alternative Proxies: