react + less制作一个箭头步骤条

效果
image.png
index.tsx
import styles from "./index.module.less";
interface Props {
  stepList: string[],
  activeIndex: number
}
export default function Index(props: Props) {
  const {
    stepList = ['基本信息', '数据来源配置', '数据结构配置', '关联元数据配置'],
    activeIndex = 1
  } = props

  return <div className={styles.stepBox}>
    {stepList.map((item, index) => <div className={styles.stepBar} key={index} data-active={activeIndex >= index ? true : false}>
      {item}
    </div>)}
  </div>
}
less
.stepBox {
  display: flex;
}

.stepBar {
  position: relative;
  width: 160px;
  height: 40px;
  line-height: 40px;
  background: #F7F8FA;
  margin: 0px 2px;
  color: #575C66;
  font-size: 14px;
  text-align: center;

  &:first-child::after {
    display: none;
  }

  &:last-child::before {
    display: none;
  }

  &[data-active='true'] {
    background: #9434DF;
    color: #fff;
    font-weight: 500;

    &::before {
      border-color: transparent transparent transparent #9434DF;
    }
  }
}

.stepBar::before {
  content: " ";
  width: 0;
  height: 0;
  border: solid;
  border-color: transparent transparent transparent #F7F8FA;
  border-top-width: 20px;
  border-right-width: 20px;
  border-bottom-width: 20px;
  border-left-width: 14px;
  position: absolute;
  right: -33px;
  top: 0px;
  z-index: 1;
}

.stepBar::after {
  content: " ";
  width: 0;
  height: 0;
  border: solid;
  border-color: transparent transparent transparent #fff;
  border-top-width: 20px;
  border-right-width: 20px;
  border-bottom-width: 20px;
  border-left-width: 14px;
  position: absolute;
  left: 0px;
  top: 0px;
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • """1.个性化消息: 将用户的姓名存到一个变量中,并向该用户显示一条消息。显示的消息应非常简单,如“Hello ...
    她即我命阅读 8,920评论 0 6
  • 为了让我有一个更快速、更精彩、更辉煌的成长,我将开始这段刻骨铭心的自我蜕变之旅!从今天开始,我将每天坚持阅...
    李薇帆阅读 6,333评论 1 4
  • 似乎最近一直都在路上,每次出来走的时候感受都会很不一样。 1、感恩一直遇到好心人,很幸运。在路上总是...
    时间里的花Lily阅读 5,411评论 1 3
  • 1、expected an indented block 冒号后面是要写上一定的内容的(新手容易遗忘这一点); 缩...
    庵下桃花仙阅读 3,813评论 0 2
  • 一、工具箱(多种工具共用一个快捷键的可同时按【Shift】加此快捷键选取)矩形、椭圆选框工具 【M】移动工具 【V...
    墨雅丫阅读 3,882评论 0 0

友情链接更多精彩内容