🐥 Moving the required asterisk to the end of form labels in Element Plus
yellowduck.be·10h
Flag this post

219 words, 2 min read

By default, Element Plus displays the required asterisk before a form label, for example: *Name. While this is functional, some design systems prefer placing the asterisk after the label instead, like Name*. Fortunately, it’s easy to adjust this behavior using either a CSS override or a custom label slot.

If you want to apply this change throughout your app, you can hide the default prefix and append your own asterisk using CSS:

.el-form-item.is-required .el-form-item__label:before {
display: none;
}
.el-form-item.is-required .el-form-item__label:after {
content: '*';
color: var(--el-color-danger);
margin-left: 4px;
}

This snippet removes the default “before” pseudo-element and adds a red asterisk to the end of each required label. You can in…

Similar Posts

Loading similar posts...