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

버튼(Button)

원문 보기 위키 갱신

버튼은 가장 기본적이면서도 자주 쓰는 UI 요소예요. 이 컴포넌트의 재미있는 점은 href prop을 주면 <button> 대신 <a> 앵커 태그로 바꿔서 렌더링할 수 있다는 거죠.

출처: 문서

본문

<script lang="ts">
  import { Button } from "bits-ui";
</script>
<Button.Root
  class="rounded-input bg-dark text-background shadow-mini hover:bg-dark/95 inline-flex
	h-12 items-center justify-center px-[21px] text-[15px]
	font-semibold active:scale-[0.98] active:transition-all"
>
  Unlimited
</Button.Root>

구조(Structure)

<script lang="ts">
  import { Button } from "bits-ui";
</script>
<Button.Root />

API 참조(API Reference)

Button.Root

href/type prop에 따라 버튼과 앵커 태그를 오갈 수 있는 컴포넌트예요.

Property Type Description Details
href string An optional prop that when passed converts the button into an anchor tag.Default:  —— undefined
disabled boolean Whether or not the button is disabled. When disabled, the button cannot be interacted with.Default: false
ref $bindable HTMLButtonElement The underlying DOM element being rendered. You can bind to this to get a reference to the element.Default: null
children Snippet The children content to render.Default:  —— undefined
Data Attribute Value Description Details
data-button-root '' Present on the button element.

더 알아보기 (Learn more)

다른 폼 요소들과 함께 쓰이고 싶다면 체크박스(Checkbox)나 인풋 요소도 함께 살펴보면 좋아요. 버튼은 Bits UI의 여러 복합 컴포넌트(예: 다이얼로그, 메뉴)에서 트리거(Trigger) 역할로도 자주 쓰인답니다.