Divider can visually separate content in a given list or group.
const Example = ( ) => {
return < Box alignItems = " center " >
< Flex direction = " row " h = " 58 " p = " 4 " >
< Text > Simple </ Text >
< Divider bg = " emerald.500 " thickness = " 2 " mx = " 2 " orientation = " vertical " />
< Text > Easy </ Text >
< Divider bg = " amber.500 " thickness = " 2 " mx = " 2 " orientation = " vertical " />
< Text > Beautiful </ Text >
</ Flex >
</ Box > ;
} ;
import { Divider } from 'native-base' ;
The Divider displays a thin horizontal or vertical line.
const Example = ( ) => {
return < Box alignItems = " center " >
< Box w = " 140 " >
< Heading mx = " 3 " alignItems = " center " flexDirection = " row " >
Chrome
</ Heading >
< Divider my = " 2 " _light = { {
bg : "muted.800"
} } _dark = { {
bg : "muted.50"
} } />
< Heading mx = " 3 " alignItems = " center " flexDirection = " row " >
Firefox
</ Heading >
</ Box >
</ Box > ;
} ;
Pass the orientation prop and set it to either horizontal or vertical .
Note: If the horizontal orientation is used, make sure that the parent element is assigned a width. If the vertical orientation is used, make sure that the parent element is assigned a height.
const Example = ( ) => {
return < Box alignItems = " center " >
< Box w = " 160 " >
< Heading mx = " auto " > Shoes </ Heading >
< Divider my = " 2 " _light = { {
bg : "muted.800"
} } _dark = { {
bg : "muted.50"
} } />
< Flex mx = " 3 " direction = " row " justify = " space-evenly " h = " 60 " >
< Heading py = " 2 " > Girls </ Heading >
< Divider orientation = " vertical " mx = " 3 " _light = { {
bg : "muted.800"
} } _dark = { {
bg : "muted.50"
} } />
< Heading py = " 2 " > Boys </ Heading >
</ Flex >
</ Box >
</ Box > ;
} ;
You can use bg or backgroundColor to change the divider's color and width and height to change its width and height respectively.
const Example = ( ) => {
return < Box alignItems = " center " >
< Flex direction = " row " h = " 58 " p = " 4 " >
< Text > Simple </ Text >
< Divider bg = " emerald.500 " thickness = " 2 " mx = " 2 " orientation = " vertical " />
< Text > Easy </ Text >
< Divider bg = " indigo.500 " thickness = " 2 " mx = " 2 " orientation = " vertical " />
< Text > Beautiful </ Text >
</ Flex >
</ Box > ;
} ;
Divider implements
,
,
,
,
,
,
,
,
,
The orientation of the divider.
Type: "horizontal" | "vertical"
The thickness of the divider.
NativeBase ships with a default theme for each component. Check out the default theme of the divider
.
Info:
We can easily extend the divider component theme using extendTheme function as described in the documentation .Divider has role set to separator and aria-orientation to either horizontal or vertical .