GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing docs.nativebase.io — Flex | NativeBase | Universal Components for React and React Native

Flex | NativeBase | Universal Components for React and React Native

NativeBase
3.4.x
🎉 Prompt to React Native UI
→
Search
⌘
K
Hire us
NativeBase
Introduction
Getting Started
Installation
Setup NativeBase Provider
Migration
Upgrading to v3
Upgrading to 3.2.0 from 3.x
Upgrading to 3.4.0 from 3.3.x
Components Migration
ActionSheet
Badge
Button
Card
Checkbox
DatePicker
DeckSwiper
Drawer
FABs
FooterTab
Form
Header
Icon
Layout
Picker
Radio Button
Searchbar
Segment
Spinner
SwipeList
Tabs
Thumbnail
Toast
Typography
Resources
Contribution
Creating a Universal App with NativeBase and Solito
Core Concepts
Utility First
Utility Props Specificity
Design Tokens
Pseudo Props: Overview
Pseudo Props: Dos & Don'ts
Internal Pseudo Props
Responsive
Features
Utility Props
Color mode (Dark Mode)
NativeBase Factory
SafeAreaView Props
Strict Mode
Accessibility
Theme
Default Theme
Customizing Theme
Customizing Fonts
Customizing Components
Making components dark mode compatible
Breakpoints
Using Theme
TypeScript
Layout
AspectRatio
Box
Center
Container
Flex
HStack / Row
Stack
VStack / Column
ZStack
Forms
Button
Pressable
Checkbox
FormControl
IconButton
Input
Link
Radio
Select
Slider
Switch
TextArea
Data Display
Badge
Divider
Feedback
Alert
Progress
Skeleton
Spinner
Toast
Typography
Text
Heading
Overlay
AlertDialog
Menu
Modal
Popover
Tooltip
Disclosure
ActionSheet
Media and Icons
Avatar
Icon
Image
Transition
PresenceTransition
Slide
Stagger
Others
Fab
Hidden
ReactNative Components
ScrollView
View
KeyboardAvoidingView
StatusBar
FlatList
SectionList
Hooks
useDisclose
useBreakpointValue
useClipboard
useMediaQuery
useTheme
useToken
useColorMode
useColorModeValue
useContrastText
useAccessibleColors
Examples
Todo-List
Kitchen Sink
Recipes
Designs
AppBar
Card
Drawer Navigation
Tab View
Swipe List
Forms
Form with Validation
Login/Signup Forms
SearchBar
Layout
App Drawer
Footer
More
Changelog
Testing
FAQ's
More Props
If you are starting a new project, please try gluestack-ui for better performance and new design.
Flex
Flex provides helpful style shorthand and is a
Box
with display: flex.
Show Code
Playground
function Example() {
const bgShade100 = useColorModeValue("primary.100", "primary.400");
const bgShade200 = useColorModeValue("primary.200", "primary.500");
const bgShade300 = useColorModeValue("primary.300", "primary.600");
const bgShade400 = useColorModeValue("primary.400", "primary.700");
return <Box flex="1" safeAreaTop>
<ScrollView _contentContainerStyle={{
h: "40",
px: "20px",
mb: "4",
minW: "72"
}}>
<VStack space={2.5} w="100%" px="3">
{
/* flexDirection -> row */
}
<Heading size="md">row</Heading>
<Flex direction="row" mb="2.5" mt="1.5" _text={{
color: "coolGray.800"
}}>
<Center size="16" bg={bgShade100}>
100
</Center>
<Center size="16" bg={bgShade200}>
200
</Center>
<Center size="16" bg={bgShade300}>
300
</Center>
<Center size="16" bg={bgShade400}>
400
</Center>
</Flex>
<Divider />
{
/* flexDirection -> column */
}
<Heading size="md">column</Heading>
<Flex direction="column" mb="2.5" mt="1.5" _text={{
color: "coolGray.800"
}}>
<Center size="16" bg={bgShade100}>
100
</Center>
<Center size="16" bg={bgShade200}>
200
</Center>
<Center size="16" bg={bgShade300}>
300
</Center>
<Center size="16" bg={bgShade400}>
400
</Center>
</Flex>
<Divider />
{
/* flexDirection -> row-reverse */
}
<Heading size="md">row-reverse</Heading>
<Flex direction="row-reverse" mb="2.5" mt="1.5" _text={{
color: "coolGray.800"
}}>
<Center size="16" bg={bgShade100}>
100
</Center>
<Center size="16" bg={bgShade200}>
200
</Center>
<Center size="16" bg={bgShade300}>
300
</Center>
<Center size="16" bg={bgShade400}>
400
</Center>
</Flex>
<Divider />
{
/* flexDirection -> column-reverse */
}
<Heading size="md">column-reverse</Heading>
<Flex direction="column-reverse" mb="2.5" mt="1.5" _text={{
color: "coolGray.800"
}}>
<Center size="16" bg={bgShade100}>
100
</Center>
<Center size="16" bg={bgShade200}>
200
</Center>
<Center size="16" bg={bgShade300}>
300
</Center>
<Center size="16" bg={bgShade400}>
400
</Center>
</Flex>
<Divider />
</VStack>
</ScrollView>
</Box>;
}
Import
Copy
import { Flex, Spacer } from "native-base";
Flex: a
Box
with display: flex
Spacer: creates an adjustable, empty space that can be used to tune the spacing between child elements within Flex
Usage
Flex components come with some helpful shorthand props:
flexDirection is direction
flexWrap is wrap
alignItems is align
justifyContent is justify
While you can pass the verbose props, using the shorthand can save you some time.
Example
Playground
function Example() {
return <Box flex="1" safeAreaTop>
<ScrollView>
<VStack space={2.5} w="100%" px="3">
{
/* flexDirection -> row */
}
<Heading size="md">row</Heading>
<Flex direction="row" mb="2.5" mt="1.5">
<Center size="16" bg="primary.100" _text={{
color: "coolGray.800"
}}>
100
</Center>
<Center size="16" bg="primary.200" _text={{
color: "coolGray.800"
}}>
200
</Center>
<Center bg="primary.300" size="16" _text={{
color: "coolGray.800"
}}>
300
</Center>
<Center size="16" bg="primary.400" _text={{
color: "coolGray.800"
}}>
400
</Center>
</Flex>
<Divider />
{
/* flexDirection -> column */
}
<Heading size="md">column</Heading>
<Flex direction="column" mb="2.5" mt="1.5">
<Center size="16" bg="primary.100" _text={{
color: "coolGray.800"
}}>
100
</Center>
<Center size="16" bg="primary.200" _text={{
color: "coolGray.800"
}}>
200
</Center>
<Center bg="primary.300" size="16" _text={{
color: "coolGray.800"
}}>
300
</Center>
<Center size="16" bg="primary.400" _text={{
color: "coolGray.800"
}}>
400
</Center>
</Flex>
<Divider />
{
/* flexDirection -> row-reverse */
}
<Heading size="md">row-reverse</Heading>
<Flex direction="row-reverse" mb="2.5" mt="1.5">
<Center size="16" bg="primary.100" _text={{
color: "coolGray.800"
}}>
100
</Center>
<Center size="16" bg="primary.200" _text={{
color: "coolGray.800"
}}>
200
</Center>
<Center bg="primary.300" size="16" _text={{
color: "coolGray.800"
}}>
300
</Center>
<Center size="16" bg="primary.400" _text={{
color: "coolGray.800"
}}>
400
</Center>
</Flex>
<Divider />
{
/* flexDirection -> column-reverse */
}
<Heading size="md">column-reverse</Heading>
<Flex direction="column-reverse" mb="2.5" mt="1.5">
<Center size="16" bg="primary.100" _text={{
color: "coolGray.800"
}}>
100
</Center>
<Center size="16" bg="primary.200" _text={{
color: "coolGray.800"
}}>
200
</Center>
<Center bg="primary.300" size="16" _text={{
color: "coolGray.800"
}}>
300
</Center>
<Center size="16" bg="primary.400" _text={{
color: "coolGray.800"
}}>
400
</Center>
</Flex>
<Divider />
</VStack>
</ScrollView>
</Box>;
}
Using the Spacer
You can pass Spacer to add Space between Flex items.
Playground
const Example = () => {
return <Flex h={40} alignItems="center">
<Center size={16} bg="primary.500" _dark={{
bg: "primary.400"
}} rounded="sm" _text={{
color: "warmGray.50",
fontWeight: "medium"
}}>
Box 1
</Center>
<Spacer />
<Center size={16} bg="secondary.500" _dark={{
bg: "secondary.400"
}} rounded="sm" _text={{
color: "warmGray.50",
fontWeight: "medium"
}}>
Box 2
</Center>
</Flex>;
};
Props
Flex implements
Box
, so all the Box Props can be passed to it, i.e.
color
,
space
,
layout
,
flexbox
&
border
props from
style-system
.
Previous
Container
Next
HStack / Row
Quick Nav
Import
Usage
Example
Using the Spacer
Props
MadeWithNativeBase
gluestack-ui
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.