Skip to content

Line Component

This component is generally used to display a line for separating content blocks. It has two modes: horizontal and vertical, and supports 0.5px lines. It is also very easy to use.

📌 Platform Differences

APP(vue)H5WeChat Mini ProgramAlipay Mini Program

🏯 Basic Usage Example

html
<!-- Global usage -->
<hy-line></hy-line>

Custom Color

html
<template>
    <hy-line color="#2979ff"></hy-line>
</template>

Custom Line Direction

Friendly Reminder

When setting the line to vertical, either the parent element must have a fixed width, or you need to set a value for length to resolve the issue of the line not being displayed.

html
<template>
    <!-- Vertical -->
    <hy-line direction="column" length="100"></hy-line>
    <!-- Horizontal -->
    <hy-line direction="row"></hy-line>
</template>

Custom Line Length

html
<template>
    <hy-line length="50%"></hy-line>
</template>

Dashed Line

html
<template>
    <hy-line dashed color="red"></hy-line>
</template>

Line Thickness

html
<template>
    <!-- Thin line -->
    <hy-line hairline></hy-line>
    <!-- Thick line -->
    <hy-line :hairline="false"></hy-line>
</template>

API

Line Props

ParameterDescriptionTypeDefault Value
colorThe color of the linestring-
lengthLength, rendered as height when vertical, and as length when horizontal. Can be a percentage, a value with rpx unit, etc.string|number100%
directionThe direction of the line, row-horizontal, column-verticalrow|columnrow
hairlineWhether to display a thin linebooleantrue
marginThe spacing between the line and surrounding elements (top, bottom, left, right), in string form, such as "30rpx", "20rpx 30rpx", default unit is pxstring0
dashedWhether the line is dashed, false-solid line, true-dashed linebooleanfalse
customStyleCustom external styles to be appliedCSSProperties-
customClassCustom external class namestring-
03:29