Textarea 텍스트 영역
Textarea는 텍스트박스에 글을 입력하거나 수정하는 컴포넌트예요. 입력할 수 있는 글자 수를 제한하는 기능까지 지원해서, 여러 줄 입력을 받는 폼을 만들 때 자주 쓰여요.
출처: 문서
본문
설치
@nutui/nutui에서 컴포넌트를 가져와 앱에 등록하면 바로 쓸 수 있어요.
import { createApp } from 'vue'
import { Textarea } from '@nutui/nutui'
const app = createApp()
app.use(Textarea)
사용 예시
기본 사용법
demo: textarea basic
글자 수 표시
demo: textarea limit
높이 커스터마이즈, 늘리기
demo: textarea row
읽기 전용, 비활성화
demo: textarea status
자동 포커스
demo: textarea focus
API
Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| v-model | input value, support two-way binding | string | - |
| placeholder | set placeholder prompt text | string | 'Placeholder' |
| max-length | limit the maximum input characters | string, number | - |
| rows | height of textarea, with priority higher than autosize attribute Only H5 is supported |
string and number | 2 |
| limit-show | whether textarea displays the input characters. Use | Boolean | false |
| autosize | whether to adapt the content height. You can also pass in objects, such as {maxheight: 200, minheight: 100}. The unit is PX | Boolean, {maxheight?: number; minheight?: number} | false |
| text-align | text position, optional values left , center, right |
string | - |
| readonly | read only attribute | Boolean | false |
| disabled | disable attribute | Boolean | false |
| autofocus | get focus automatically | Boolean | false |
Events
| Event | Description | Arguments |
|---|---|---|
| change | Triggered when the value of the input box changes | value |
| focus | Triggered when focusing | event |
| blur | Triggered when out of focus | value,event |
Types v4.3.4
이 컴포넌트는 아래 타입 정의를 함께 내보내요.
import type { TextareaProps, TextareaInstance } from '@nutui/nutui';
Theming
CSS Variables
스타일 커스텀에 쓸 수 있는 CSS 변수를 제공해요. 자세한 내용은 ConfigProvider 컴포넌트를 참고하세요.
| Name | Default Value |
|---|---|
| --nut-textarea-font | var(--nut-font-size-2) |
| --nut-textarea-limit-color | var(--nut-text-color) |
| --nut-textarea-text-color | var(--nut-title-color) |
| --nut-textarea-disabled-color | var(--nut-disable-color) |
더 알아보기 (Learn more)
- 원문 문서: NutUI Textarea 공식 문서(영문)
- NutUI는 JD.com이 공개한 Vue 3 모바일 컴포넌트 라이브러리예요. 전체 컴포넌트 목록은 공식 문서 사이트에서, 소스 코드는 GitHub 저장소에서 볼 수 있어요.