본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Button — 버튼

원문 보기 위키 갱신

버튼은 폼 제출처럼 어떤 동작을 시작하게 만들 때 쓰는 기본 컴포넌트예요. 타입·크기·모양·색상 등 스타일 변형을 조합해 화면에 필요한 버튼을 대부분 만들 수 있어요.

출처: Button — doc.en-US.md

소개

버튼은 폼 제출처럼 동작을 트리거할 때 사용해요.

설치

import { createApp } from 'vue'
import { Button } from '@nutui/nutui'

const app = createApp()
app.use(Button)

타입

버튼은 default, primary, info, warning, danger, success 여섯 가지 타입을 지원하고, 기본값은 default예요.

demo: button type

플레인(테두리만)

plain 속성으로 버튼을 플레인 버튼으로 만들 수 있어요. 플레인 버튼은 글자색이 버튼 색상이고 배경은 흰색이에요.

demo: button plain

비활성화

disabled 속성으로 버튼을 비활성화해요. 비활성 상태에서는 버튼을 클릭할 수 없어요.

demo: button disabled

모양

shape 속성으로 버튼 모양을 정해요. 원형(circle)과 사각(square) 버튼을 지원하고, 기본값은 circle이에요.

demo: button shape

로딩

demo: button loading

아이콘

demo: button icon

크기

large, normal, small, mini 네 가지 크기를 지원하고, 기본값은 normal이에요.

demo: button size

블록

기본적으로 버튼은 inline-block 요소예요. block 속성으로 버튼의 요소 타입을 block으로 바꿀 수 있고, 배너 하단 버튼처럼 가로를 가득 채우는 버튼에 자주 쓰여요.

demo: button block

색상 커스터마이즈

color 속성으로 버튼 색상을 직접 정할 수 있어요.

demo: button color

API

Props

Attribute Description Type Default
type Can be set to primary info warning danger success default string default
size Can be set to large small mini normal string normal
shape Can be set to square round string round
color Button color, support incoming linear-gradient gradient color string -
plain Whether to be plain button boolean false
disabled Whether to disable button boolean false
block Whether to set display block boolean false
loading Whether to show loading status boolean false

Slots

Name Description
default button content
icon button icon

Events

Event Description Arguments
click Emitted when component is clicked event: MouseEvent

Types v4.3.0

컴포넌트는 아래 타입 정의를 export해요.

import type {
  ButtonType,
  ButtonSize,
  ButtonShape,
  ButtonFormType,
  ButtonProps,
  ButtonInstance
} from '@nutui/nutui';

테마 (Theming)

CSS 변수

이 컴포넌트는 스타일을 커스터마이징할 때 쓸 수 있는 CSS 변수를 제공해요. 자세한 내용은 ConfigProvider 컴포넌트 문서를 참고하세요.

Name Default Value
--nut-button-border-radius 25px
--nut-button-border-width 1px
--nut-button-icon-width 16px
--nut-button-default-bg-color var(--nut-white)
--nut-button-default-border-color rgba(204, 204, 204, 1)
--nut-button-default-color rgba(102, 102, 102, 1)
--nut-button-default-padding 0 18px
--nut-button-mini-padding 0 12px
--nut-button-small-padding 0 12px
--nut-button-small-height 28px
--nut-button-mini-height 24px
--nut-button-default-height 38px
--nut-button-large-height 48px
--nut-button-large-line-height 46px
--nut-button-small-line-height 26px
--nut-button-block-height 48px
--nut-button-default-line-height 36px
--nut-button-block-line-height 46px
--nut-button-default-font-size var(--nut-font-size-2)
--nut-button-large-font-size var(--nut-button-default-font-size)
--nut-button-small-font-size var(--nut-font-size-1)
--nut-button-mini-font-size var(--nut-font-size-1)
--nut-button-mini-line-height 1.2
--nut-button-disabled-opacity 0.68
--nut-button-primary-color var(--nut-white)
--nut-button-primary-border-color var(--nut-primary-color)
--nut-button-primary-background-color linear-gradient(135deg,var(--nut-primary-color) 0%,var(--nut-primary-color-end) 100%)
--nut-button-info-color var(--nut-white)
--nut-button-info-border-color rgba(73, 106, 242, 1)
--nut-button-info-background-color linear-gradient(315deg, rgba(73, 143, 242, 1) 0%, rgba(73, 101, 242, 1) 100%)
--nut-button-success-color var(--nut-white)
--nut-button-success-border-color rgba(38, 191, 38, 1)
--nut-button-success-background-color linear-gradient(135deg,rgba(38, 191, 38, 1) 0%,rgba(39, 197, 48, 1) 45%,rgba(40, 207, 63, 1) 83%,rgba(41, 212, 70, 1) 100%)
--nut-button-danger-color var(--nut-white)
--nut-button-danger-border-color rgba(250, 44, 25, 1)
--nut-button-danger-background-color rgba(250, 44, 25, 1)
--nut-button-warning-color var(--nut-white)
--nut-button-warning-border-color rgba(255, 158, 13, 1)
--nut-button-warning-background-color linear-gradient(135deg,rgba(255, 158, 13, 1) 0%,rgba(255, 167, 13, 1) 45%,rgba(255, 182, 13, 1) 83%,rgba(255, 190, 13, 1) 100%)
--nut-button-plain-background-color var(--nut-white)
--nut-button-small-round-border-radius var(--nut-button-border-radius)

더 알아보기 (Learn more)

이 문서는 NutUI v4 공식 영문 문서를 한국어로 옮긴 글이에요. 최신 API와 변경 사항은 원문에서 확인하는 게 가장 정확해요.