DashboardSearchButton

ButtonGitLab
Um Button pré-estilizado para abrir o modal do DashboardSearch.

Uso

O componente DashboardSearchButton é usado para abrir o modal do DashboardSearch.

<template>
  <NDashboardSearchButton />
</template>

Ele estende o componente Button, então você pode passar qualquer propriedade como color, variant, size, etc.

<template>
  <NDashboardSearchButton variant="subtle" />
</template>
O botão usa por padrão color="neutral" e variant="outline" quando não está recolhido, e variant="ghost" quando recolhido.

Recolhido

Use a prop collapsed para ocultar o rótulo do botão e os kbds. O padrão é false.

<template>
  <NDashboardSearchButton collapsed />
</template>
Ao usar o botão no componente DashboardSidebar, use a prop de slot collapsed diretamente.

Kbds

Use a prop kbds para exibir teclas do teclado no botão. O padrão é ['meta', 'K'] para corresponder ao atalho padrão do componente DashboardSearch.

<template>
  <NDashboardSearchButton :kbds="['alt', 'O']" />
</template>

API

Props

Prop Default Type
as'button'any

The element or component this component should render as when not a link.

iconappConfig.ui.icons.searchany

The icon displayed in the button. Set to false to hide the icon.

labelt('dashboardSearchButton.label') string

The label displayed in the button.

color'neutral' "error" | "neutral" | "primary" | "secondary" | "accent" | "success" | "info" | "warning"

The color of the button.

variant "solid" | "outline" | "soft" | "subtle" | "ghost" | "link"

The variant of the button. Defaults to 'outline' when not collapsed, 'ghost' when collapsed.

collapsedfalseboolean

Whether the button is collapsed.

tooltipfalseboolean | TooltipProps

Display a tooltip on the button when is collapsed with the button label. This has priority over the global tooltip prop.

kbds["meta", "k"] (string | undefined)[] | KbdProps[]

The keyboard keys to display in the button. { variant: 'subtle' }

autofocus false | true | "true" | "false"
disabledboolean
name string
type'button' "reset" | "submit" | "button"

The type of the button when not a link.

activeColor "error" | "neutral" | "primary" | "secondary" | "accent" | "success" | "info" | "warning"
activeVariant "solid" | "outline" | "soft" | "subtle" | "ghost" | "link"
size'md' "xs" | "sm" | "md" | "lg" | "xl"
squareboolean

Render the button with equal padding on all sides.

blockboolean

Render the button full width.

loadingAutoboolean

Set loading state automatically based on the @click promise state

avatar AvatarProps

Display an avatar on the left side.

leadingboolean

When true, the icon will be displayed on the left side.

leadingIconany

Display an icon on the left side.

trailingboolean

When true, the icon will be displayed on the right side.

trailingIconany

Display an icon on the right side.

loadingboolean

When true, the loading icon will be displayed.

loadingIconappConfig.ui.icons.loadingany

The icon when the loading prop is true.

ui { base?: SlotClass; label?: SlotClass; trailing?: SlotClass; } & { base?: SlotClass; label?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailingIcon?: SlotClass; }
Este componente também suporta todos os atributos HTML nativos de <button>.

Slots

Slot Type
leading{ ui: object; }
default{ ui: object; }
trailing{ ui: object; }

Tema

app.config.ts
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'
          }
        }
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nitro/ui/vite'

export default defineConfig({
  plugins: [
    vue(),
    ui({
      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

No recent changes