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

FieldGroup

원문 보기 위키 갱신

여러 버튼처럼 생긴 요소를 하나로 묶어 주는 컴포넌트예요.

출처: Nuxt UI

본문

사용법

여러 Button을 FieldGroup 안에 감싸서 묶어줄 수 있어요.

<template>
  <UFieldGroup>
    <UButton color="neutral" variant="subtle" label="Button" />
    <UButton color="neutral" variant="outline" icon="i-lucide-chevron-down" />
  </UFieldGroup>
</template>

Size

size prop으로 모든 버튼의 크기를 바꿀 수 있어요.

<template>
  <UFieldGroup size="xl">
    <UButton color="neutral" variant="subtle" label="Button" />
    <UButton color="neutral" variant="outline" icon="i-lucide-chevron-down" />
  </UFieldGroup>
</template>

Orientation

orientation prop으로 버튼의 배치 방향을 바꿀 수 있어요. 기본값은 horizontal이에요.

<template>
  <UFieldGroup orientation="vertical">
    <UButton color="neutral" variant="subtle" label="Submit" />
    <UButton color="neutral" variant="outline" label="Cancel" />
  </UFieldGroup>
</template>

예시

입력 요소와 함께 사용하기

Input, InputMenu, Select, SelectMenu 같은 컴포넌트를 필드 그룹 안에서 함께 사용할 수 있어요.

<template>
  <UFieldGroup>
    <UInput color="neutral" variant="outline" placeholder="Enter token" />

    <UButton color="neutral" variant="subtle" icon="i-lucide-clipboard" />
  </UFieldGroup>
</template>

툴팁과 함께 사용하기

필드 그룹 안에 Tooltip을 사용할 수 있어요.

<template>
  <UFieldGroup>
    <UInput color="neutral" variant="outline" placeholder="Enter token" />

    <UTooltip text="Copy to clipboard">
      <UButton
        color="neutral"
        variant="subtle"
        icon="i-lucide-clipboard"
      />
    </UTooltip>
  </UFieldGroup>
</template>

드롭다운 메뉴와 함께 사용하기

필드 그룹 안에 DropdownMenu을 사용할 수 있어요.

<script setup lang="ts">
import type { DropdownMenuItem } from '@nuxt/ui'

const items: DropdownMenuItem[] = [
  {
    label: 'Team',
    icon: 'i-lucide-users'
  },
  {
    label: 'Invite users',
    icon: 'i-lucide-user-plus',
    children: [
      {
        label: 'Invite by email',
        icon: 'i-lucide-send-horizontal'
      },
      {
        label: 'Invite by link',
        icon: 'i-lucide-link'
      }
    ]
  },
  {
    label: 'New team',
    icon: 'i-lucide-plus'
  }
]
</script>

<template>
  <UFieldGroup>
    <UButton color="neutral" variant="subtle" label="Settings" />

    <UDropdownMenu :items="items">
      <UButton
        color="neutral"
        variant="outline"
        icon="i-lucide-chevron-down"
      />
    </UDropdownMenu>
  </UFieldGroup>
</template>

배지와 함께 사용하기

필드 그룹 안에 Badge를 사용할 수 있어요.

<template>
  <UFieldGroup>
    <UBadge color="neutral" variant="outline" size="lg" label="https://" />

    <UInput color="neutral" variant="outline" placeholder="www.example.com" />
  </UFieldGroup>
</template>

API

Props

/**
 * Props for the FieldGroup component
 */
interface FieldGroupProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  /**
   * @default 'md'
   */
  size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
  /**
   * The orientation the buttons are laid out.
   * @default 'horizontal'
   */
  orientation?: "horizontal" | "vertical" | undefined;
  ui?: { base?: any; } | undefined;
}

Slots

/**
 * Slots for the FieldGroup component
 */
interface FieldGroupSlots {
  default(): any;
}

테마

export default defineAppConfig({
  ui: {
    fieldGroup: {
      base: 'relative',
      variants: {
        size: {
          xs: '',
          sm: '',
          md: '',
          lg: '',
          xl: ''
        },
        orientation: {
          horizontal: 'inline-flex -space-x-px',
          vertical: 'flex flex-col -space-y-px'
        }
      },
      defaultVariants: {
        size: 'md'
      }
    }
  }
})

변경 기록

컴포넌트와 테마의 커밋 기록을 확인해 주세요.


사이트맵

전체 페이지 목록은 사이트맵에서 확인할 수 있어요.

더 알아보기 (Learn more)