Divider
The Divider
component in Pearl UI is a versatile tool used to create a visual separation between different sections of content in a list or group. It can be customized in terms of orientation, color, size, and more.
#
Importimport { Divider } from "pearl-ui";
#
Usage// Basic usage of Divider<Divider />
// Customizing Divider with orientation and color<Divider orientation="horizontal" bgColor="red" />
// Using Divider in a list<View> <Text>Item 1</Text> <Divider orientation="horizontal" /> <Text>Item 2</Text> <Divider orientation="horizontal" /> <Text>Item 3</Text></View>
#
Changing Divider OrientationThe Divider
's orientation can be changed using the orientation
prop. This allows you to set the direction of the divider as either horizontal or vertical.
<Divider orientation="horizontal" />
<Divider orientation="vertical" />
#
Overriding Default StylesThe Divider
component supports a variety of style props which can be used to override the pre-defined styles in the theme. Any manual style props passed into the component will take precedence over the default component configuration.
// Example: Overriding the default background color<Divider bgColor="red" />
#
Example#
Component Properties#
Supported Style PropertiesThe Divider
component supports the following style props:
- backgroundColor (Only
backgroundColor
props are supported, not thecolor
prop) - layout
- transform
- position
- opacity and visiblity
- margin and padding
#
Animation PropertiesThe Divider
component inherits animation properties from the Box
component, which are managed by the Moti library. This allows for the creation of dynamic and interactive UI elements. The useMotiWithStyleProps hook from the Moti library is utilized to manage these animation properties.
Property | Type | Default | Description |
---|---|---|---|
from | Defines the starting state of the animation. | ||
to | Defines the ending state of the animation. | ||
transition | Specifies the type of transition that the animation will use. | ||
exitTransition | Determines the transition type that will be used when the component is unmounted. By default, exit uses transition to configure its animations, so this prop is not required. However, if you pass exitTransition , it will override transition for exit animations. | ||
state | Manages the overall state of the animation, including the from and to states. | ||
delay | Manage the delay for the animate field. (Use the transition prop for more granular control) | ||
onDidAnimate | Callback function called after finishing an animation. | ||
stylePriority | "animate" | This is not a prop you will likely find yourself using. If set to animate prop will take precedent. Otherwise, if set to state prop will take precedent for matching styles. | |
animateInitialState | false | If true , the from prop will be set to animate. This will be noticeable for some spring animations, and might make them jumpy on mount. |
#
Additional PropertiesThe Divider
component also accepts the following additional props:
Name | Required | Type | Default | Description |
---|---|---|---|---|
size | false | The size of the divider | ||
variant | false | The variant of the divider | ||
thickness | false | 1 | The thickness of the divider | |
length | false | "100%" | The length of the divider | |
orientation | false | "horizontal" | The direction of the divider |