Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/web/api/textarea.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Limits the maximum number of characters entered and displays the number of chara

{{ maxlength }}

### Clearable Textarea

Textarea with a clear operation can quickly clear entered content.

{{ clearable }}

### Binding DOM Events

You can bind DOM native events such as `onKeypress` `onKeydown` `onKeyup` `onFocus` `onBlur`.
Expand Down
6 changes: 6 additions & 0 deletions docs/web/api/textarea.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ spline: form

{{ maxlength }}

### 可清空的多行文本框

带清空操作的多行文本框,可快捷清空输入过的内容。

{{ clearable }}

### 绑定 DOM 事件

可绑定 `onKeypress` `onKeydown` `onKeyup` `onFocus` `onBlur` 等 DOM 原生事件。
Expand Down
4 changes: 4 additions & 0 deletions style/web/components/textarea/_index.less
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
.@{prefix}-hide-scrollbar {
.hideScrollbar();
}

&.@{prefix}-textarea--clearable {
.textarea-clearable();
}
}

.@{prefix}-textarea__tips {
Expand Down
31 changes: 31 additions & 0 deletions style/web/components/textarea/_mixin.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,34 @@
}
}
}

.textarea-clearable() {
.@{prefix}-textarea__inner {
padding-right: @textarea-clear-padding-right;
}

.@{prefix}-textarea__clear {
position: absolute;
right: @textarea-clear-position-right;
top: @textarea-clear-position-top;
transform: translateY(-50%);
width: @textarea-clear-size;
height: @textarea-clear-size;
cursor: pointer;
font-size: @textarea-clear-size;
color: @textarea-clear-color;
opacity: 0;
visibility: hidden;
transition: @textarea-clear-transition;
z-index: 1;

&:hover {
color: @textarea-clear-color-hover;
}
}

.@{prefix}-textarea__clear--visible {
opacity: 1;
visibility: visible;
}
}
15 changes: 14 additions & 1 deletion style/web/components/textarea/_var.less
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
@textarea-tips-font: @font-body-small;

// 间距
@textarea-padding: calc(calc(@comp-size-m - @text-line-height-base) / 2) @comp-paddingLR-s;
@textarea-padding-top: calc(calc(@comp-size-m - @text-line-height-base) / 2);
@textarea-padding: @textarea-padding-top @comp-paddingLR-s;
@textarea-tips-gap: @comp-margin-s;

// 边框
Expand All @@ -52,3 +53,15 @@
@textarea-box-shadow-color-error-focus: @error-color-focus;

@textarea-border-radius: @border-radius-default;

// 清除按钮
@textarea-clear-color: @text-color-placeholder;
@textarea-clear-color-hover: @text-color-secondary;
@textarea-clear-size: @font-size-l;
@textarea-clear-position-right: @comp-paddingLR-s;
@textarea-clear-position-top: calc(@textarea-padding-top + calc(@text-line-height-base / 2));
@textarea-clear-padding-right: calc(@comp-paddingLR-s + @textarea-clear-size + @comp-margin-s);
@textarea-clear-transition:
opacity @anim-duration-base linear,
visibility @anim-duration-base linear,
color @anim-duration-base linear;