Skip to content
ReferenceVersion 6.0.2

RMoreDropdown ​

Wraps NDropdown with a default more-actions icon for row actions. options, trigger, placement, onSelect(key, option), and controlled visibility follow Naive UI Dropdown.

Interactive example ​

View example source
vue
<template>
  <DemoFrame>
    <div class="ray-demo">
      <RMoreDropdown trigger="click" :options="options" @select="onSelect">
        <NButton>{{ copy.more }}</NButton>
      </RMoreDropdown>
      <output class="ray-demo-result">{{ result || copy.hint }}</output>
    </div>
  </DemoFrame>
</template>

<script setup lang="ts">
import { RMoreDropdown } from '@ray-template/ui/more-dropdown'
import { NButton } from 'naive-ui'
import { useData } from 'vitepress'
import { computed, ref } from 'vue'
import DemoFrame from './DemoFrame.vue'

const { lang } = useData()
const copy = computed(() =>
  lang.value.startsWith('en')
    ? {
        edit: 'Edit',
        copy: 'Duplicate',
        archive: 'Archive',
        more: 'More actions',
        hint: 'Select an action.',
      }
    : {
        edit: '编辑',
        copy: '复制',
        archive: '归档',
        more: '更多操作',
        hint: '请选择一项操作',
      },
)
const options = computed(() => [
  { key: 'edit', label: copy.value.edit },
  { key: 'copy', label: copy.value.copy },
  { key: 'archive', label: copy.value.archive, disabled: true },
])
const result = ref('')
const onSelect = (key: string | number) => {
  result.value = options.value.find((option) => option.key === key)?.label ?? ''
}
</script>
PropDefaultDescription
icon'action/more'IconName using the full group-qualified path.
iconSizeRIcon defaultTrigger icon size. Omission uses 20 px.
cursor'inherit'Inherits the parent control's pointer style.
triggerLabelInjected translation or 'More actions'Accessible name of the default icon button.

The default trigger is a keyboard-focusable icon button. placement defaults to 'bottom-start' and can be overridden. The default slot replaces the entire trigger. Give a custom native button or NButton an accessible name. Stop click propagation as needed in a row so opening the menu does not also navigate.

tsx
import { RIcon, RMoreDropdown } from '@/components'
import { NButton } from 'naive-ui'

export const renderRowActions = (edit: () => void) => (
  <RMoreDropdown
    trigger="click"
    placement="bottom-end"
    options={[{ key: 'edit', label: 'Edit' }]}
    onSelect={(key) => {
      if (key === 'edit') edit()
    }}
  >
    <NButton
      text
      aria-label="More actions"
      onClick={(event) => event.stopPropagation()}
    >
      <RIcon name="action/more" />
    </NButton>
  </RMoreDropdown>
)

Component implementation · Props