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

DashboardSearchButton

원문 보기 위키 갱신

DashboardSearchButton (대시보드 검색 버튼)

DashboardSearchButton은 DashboardSearch 모달을 여는 미리 스타일된 Button이에요. 대시보드 헤더나 사이드바에 검색 진입점을 빠르게 만들 수 있어요.

출처: Nuxt UI

본문

DashboardSearchButton 컴포넌트는 DashboardSearch 모달을 여는 데 사용돼요.

<template>
  <UDashboardSearchButton />
</template>

이 컴포넌트는 Button 컴포넌트를 확장하므로 color, variant, size 등 모든 속성을 전달할 수 있어요.

<template>
  <UDashboardSearchButton variant="subtle" />
</template>

[!NOTE] 참고: #collapsed

접히지 않은 상태에서는 버튼이 기본값으로 color="neutral", variant="outline"을 사용하고, 접힌 상태에서는 variant="ghost"를 사용해요.

접힘 (Collapsed)

collapsed prop을 사용해 버튼의 라벨과 kbds를 숨길 수 있어요. 기본값은 false예요.

<template>
  <UDashboardSearchButton collapsed />
</template>

[!TIP] 참고: /docs/components/dashboard-sidebar#slots

DashboardSidebar 컴포넌트에서 버튼을 사용할 때는 collapsed 슬롯 prop을 직접 사용하세요.

키보드 키 (Kbds)

kbds prop을 사용해 버튼에 키보드 키를 표시할 수 있어요. 기본값은 DashboardSearch 컴포넌트의 기본 단축키와 맞추기 위해 ['meta', 'K']예요.

<template>
  <UDashboardSearchButton :collapsed="false" :kbds="[
  'alt',
  'O'
]" />
</template>

API

Props

/**
 * Props for the DashboardSearchButton component
 */
interface DashboardSearchButtonProps {
  /**
   * The icon displayed in the button. Set to `false` to hide the icon.
   * @default appConfig.ui.icons.search
   */
  icon?: any;
  /**
   * The label displayed in the button.
   * @default t('dashboardSearchButton.label')
   */
  label?: string | undefined;
  /**
   * The color of the button.
   * @default 'neutral'
   */
  color?: "error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning" | undefined;
  /**
   * The variant of the button.
   * Defaults to 'outline' when not collapsed, 'ghost' when collapsed.
   */
  variant?: "solid" | "outline" | "soft" | "subtle" | "ghost" | "link" | undefined;
  /**
   * Whether the button is collapsed.
   * @default false
   */
  collapsed?: boolean | undefined;
  /**
   * Display a tooltip on the button when is collapsed with the button label.
   * This has priority over the global `tooltip` prop.
   * @default false
   */
  tooltip?: boolean | TooltipProps | undefined;
  /**
   * The keyboard keys to display in the button.
   * `{ variant: 'subtle' }`{lang="ts-type"}
   * @default ["meta", "k"]
   */
  kbds?: (string | undefined)[] | KbdProps[] | undefined;
  ui?: { base?: SlotClass; label?: SlotClass; trailing?: SlotClass; } & { base?: SlotClass; label?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailingIcon?: SlotClass; } | undefined;
  /**
   * Class to apply when the link is exact active
   */
  exactActiveClass?: string | undefined;
  /**
   * Pass the returned promise of `router.push()` to `document.startViewTransition()` if supported.
   */
  viewTransition?: boolean | undefined;
  autofocus?: false | true | "true" | "false" | undefined;
  disabled?: boolean | undefined;
  form?: string | undefined;
  formaction?: string | undefined;
  formenctype?: string | undefined;
  formmethod?: string | undefined;
  formnovalidate?: false | true | "true" | "false" | undefined;
  formtarget?: string | undefined;
  name?: string | undefined;
  /**
   * The type of the button when not a link.
   * @default 'button'
   */
  type?: "reset" | "submit" | "button" | undefined;
  onClick?: (event: MouseEvent): void | ((event: MouseEvent) => void)[] | undefined;
  /**
   * The element or component this component should render as when not a link.
   * @default 'button'
   */
  as?: any;
  activeColor?: "error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning" | undefined;
  activeVariant?: "solid" | "outline" | "soft" | "subtle" | "ghost" | "link" | undefined;
  /**
   * @default 'md'
   */
  size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
  /**
   * Render the button with equal padding on all sides.
   */
  square?: boolean | undefined;
  /**
   * Render the button full width.
   */
  block?: boolean | undefined;
  /**
   * Set loading state automatically based on the `@click` promise state
   */
  loadingAuto?: boolean | undefined;
  /**
   * Display an avatar on the left side.
   */
  avatar?: AvatarProps | undefined;
  /**
   * When `true`, the icon will be displayed on the left side.
   */
  leading?: boolean | undefined;
  /**
   * Display an icon on the left side.
   */
  leadingIcon?: any;
  /**
   * When `true`, the icon will be displayed on the right side.
   */
  trailing?: boolean | undefined;
  /**
   * Display an icon on the right side.
   */
  trailingIcon?: any;
  /**
   * When `true`, the loading icon will be displayed.
   */
  loading?: boolean | undefined;
  /**
   * The icon when the `loading` prop is `true`.
   * @default appConfig.ui.icons.loading
   */
  loadingIcon?: any;
}

[!NOTE] 참고: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes

이 컴포넌트는 기본 <button> HTML 속성도 모두 지원해요.

Slots

/**
 * Slots for the DashboardSearchButton component
 */
interface DashboardSearchButtonSlots {
  leading(): any;
  default(): any;
  trailing(): any;
}

테마 (Theme)

export default defineAppConfig({
  ui: {
    dashboardSearchButton: {
      slots: {
        base: '',
        label: '',
        trailing: 'hidden lg:flex items-center gap-0.5 ms-auto'
      },
      variants: {
        collapsed: {
          true: {
            label: 'hidden',
            trailing: 'lg:hidden'
          }
        }
      }
    }
  }
})

변경 로그 (Changelog)

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

더 알아보기 (Learn more)