Border
Brief Introduction
The Border component is used to add border styles to elements, supporting multiple border styles, colors, and directions. You can use <MYBorder></MYBorder> or <MYBorder /> to configure the border.
About Basic Borders
borderStyle
Use borderStyle to define the basic style of the border.
The default color is black; here we use borderColor to set a clear color.
borderWidth
Use borderWidth to define the thickness of the border. Default is 1px. Here we use borderColor to set a clear color.
borderColor
Use borderColor to define the color of the border. Default is black; here we use borderStyle="dashed" together.
Border Directions
You can set a separate color for each direction of the border. If you set a color for a single direction, the default border color becomes white.
Center Content
Use center to center the content inside the border. Here we use borderColor to set a clear color.
Rounded Corners
Use the rounded prop to add rounded corners to the border. Here we use borderColor to set a clear color. For better visualization, we also use paddingText to move the text.
Circle Shape
Use the circular prop to turn the border into a circle. Here we use borderColor to set a clear color. For better visualization, we also use paddingText to move the text.
Background Color Inside Border
Use colorBackground to set the background color inside the border.
Text Color Inside Border
Use textColor to set the color of the text inside the border.
Shadow
Use boxShadow to add a shadow effect to the border. Its usage is the same as the native CSS box-shadow property.
Custom Width and Height
Use the width and height props to set the dimensions. For better visualization, we also use paddingText to move the text and borderColor to set a color. Width and height can be used independently.
Spacing Between Content and Border
Use paddingText to set the distance between the content and the border. It works like the native CSS padding property, and its usage is the same as CSS padding.
Finally, here is a combination of multiple props:
Note:
· If you set colors for border directions,
borderStyleandborderWidthwill be overridden, andborderStylewill no longer take effect.
· If bothborderColorand directional color props are set, the directional colors will overrideborderColor. Therefore, use only one style at a time.
· Ifcircularis set,roundedwill not take effect.circularandroundedcan only be used one at a time.
API Reference
Props
| Prop | Description | Type | Options | Default |
|---|---|---|---|---|
| borderStyle | Border style | string | solid/dashed/dotted/double | solid |
| borderWidth | Border thickness | string | px/rem/vh/vw | 1px |
| borderColor | Border color | string | Hex or named color | — |
| topColor | Top border color | string | Hex or named color | — |
| bottomColor | Bottom border color | string | Hex or named color | — |
| leftColor | Left border color | string | Hex or named color | — |
| rightColor | Right border color | string | Hex or named color | — |
| rounded | Rounded corners | boolean | — | false |
| circular | Circle shape | boolean | — | false |
| colorBackground | Background color | string | Hex or named color | — |
| textColor | Text color | string | Hex or named color | — |
| boxShadow | Shadow effect | string | Any CSS shadow format | — |
| width | Border width | string | px/rem/vh/vw | — |
| height | Border height | string | px/rem/vh/vw | — |
| paddingText | Spacing between content and border | string | px/rem/vh/vw | — |
| tag | Rendered HTML tag | string | Any HTML tag | div |
Type Definitions
interface BorderProps {
borderStyle?: 'solid' | 'dashed' | 'dotted' | 'double';
borderWidth?: string;
borderColor?: string;
topColor?: string;
bottomColor?: string;
leftColor?: string;
rightColor?: string;
rounded?: boolean;
circular?: boolean;
colorBackground?: string;
textColor?: string;
boxShadow?: string;
width?: string;
height?: string;
paddingText?: string;
tag?: string;
}