InputNumber
InputNumber (숫자 입력)
버튼 클릭으로 숫자를 늘리거나 줄이는 컴포넌트예요. 최소·최대 범위 제한, 스텝 크기, 소수점 자릿수 같은 숫자 입력의 기본 요구를 옵션으로 다뤄요.
출처: 문서
본문
소개 (Intro)
버튼을 클릭해서 숫자를 증가시키거나 감소시켜요.
설치 (Install)
import { createApp } from 'vue'
import { InputNumber } from '@nutui/nutui'
const app = createApp()
app.use(InputNumber)
데모 (Demos)
아래 항목들은 원문 문서의 대화형 데모로 제공돼요.
- 기본 사용법 (Basic Usage) —
demo: inputnumber basic - 스텝 크기 설정 (Step size setting) —
demo: inputnumber step - 입력 범위 제한 (Limit input range) —
demo: inputnumber limit - 비활성 상태 (Disabled state) —
demo: inputnumber disabled - 읽기 전용으로 입력 상자 비활성화 (Read only disable input box) —
demo: inputnumber readonly - 소수점 지원 (Support decimal point) —
demo: inputnumber decimal - 커스텀 버튼 크기 (Custom button size) —
demo: inputnumber size - 커스텀 아이콘 이름 (Custsom icon name) —
demo: inputnumber icon
스텝 크기 설정 (Step size setting)
스텝 step을 5로 설정해요.
입력 범위 제한 (Limit input range)
min과 max 속성은 각각 최솟값과 최댓값을 나타내요.
비활성 상태 (Disabled state)
disabled가 비활성화되면 버튼을 클릭할 수 없고 입력 상자도 수정할 수 없어요.
읽기 전용으로 입력 상자 비활성화 (Read only disable input box)
readonly로 읽기 전용을 설정해 입력 상자의 입력 동작을 막아요.
소수점 지원 (Support decimal point)
스텝 크기 step을 0.1로, decimal places(소수 자릿수)를 1로 설정해 소수점 첫째 자리까지 유지해요.
API
Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| v-model | Initial value | string | number | - |
| input-width | Input box width | string | `` |
| button-size | Operators +, - Dimensions | string | `` |
| min | Minimum limit | string | number | 1 |
| max | Maximum limit | string | number | 9999 |
| step | step | string | number | 1 |
| decimal-places | Set reserved decimal places | string | number | 0 |
| disabled | Disable all features | boolean | false |
| readonly | Read only status disables input box operation behavior | boolean | false |
Attrs v4.3.5
InputNumber에 지정한 속성은 input 엘리먼트로 상속돼요.
Slots
| Name | Description |
|---|---|
| left-icon | Custom left icon |
| right-icon | Custom right icon |
Events
| Event | Description | Arguments |
|---|---|---|
| add | Triggered when the Add button is clicked | event: Event |
| reduce | Triggered when the decrease button is clicked | event: Event |
| overlimit | Triggered when an unavailable button is clicked | event: Event,type:string (reduce or add) |
| change | Triggered when the value changes | value: number , event : Event |
| blur | Triggered when the input box blur | event: Event |
| focus | Triggered when the input box focus | event: Event |
Types v4.3.3
컴포넌트는 다음 타입 정의를 export해요:
import type {
InputNumberProps,
InputNumberInstance
} from '@nutui/nutui';
Theming
CSS Variables
The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
| Name | Default Value |
|---|---|
| --nut-inputnumber-icon-color | var(--nut-title-color) |
| --nut-inputnumber-icon-void-color | var(--nut-disable-color) |
| --nut-inputnumber-icon-size | 20px |
| --nut-inputnumber-input-width | 40px |
| --nut-inputnumber-input-font-size | 12px |
| --nut-inputnumber-input-font-color | var(--nut-title-color) |
| --nut-inputnumber-input-background-color | var(--nut-help-color) |
| --nut-inputnumber-input-border-radius | 4px |
| --nut-inputnumber-input-margin | 0 6px |
| --nut-inputnumber-input-border | 0 |
| --nut-inputnumber-border | 0 |
| --nut-inputnumber-border-radius | 0 |
| --nut-inputnumber-height | auto |
| --nut-inputnumber-line-height | normal |
| --nut-inputnumber-border-box | content-box |
| --nut-inputnumber-display | inline-flex |
더 알아보기 (Learn more)
- 원문 문서: InputNumber — NutUI v4 영문 문서
- NutUI 저장소: jd-opensource/nutui