Skip to content
On this page

NcActions

The Actions component can be used to display one ore more actions. If only a single action is provided, it will be rendered as an inline icon. For more, a menu indicator will be shown and a popovermenu containing the actions will be opened on click.

Since: 0.10.0

Props

Prop nameDescriptionTypeValuesDefault
openSpecify the open state of the popover menuboolean-false
forceMenuForce the actions to display in a three dot menuboolean-false
forceTitleForce the title to show for single actionsboolean-false
menuTitleSpecify the menu titlestring-null
primaryApply primary styling for this menuboolean-false
typeSpecifies the button type used for trigger and single actions buttons
Accepted values: primary, secondary, tertiary, tertiary-no-background, tertiary-on-primary, error, warning, success. If left empty,
the default button style will be applied.
stringprimary, secondary, tertiary, tertiary-no-background, tertiary-on-primary, error, warning, successnull
defaultIconIcon to show for the toggle menu button
when more than one action is inside the actions component.
Only replace the default three-dot icon if really necessary.
string-''
ariaLabelAria label for the actions menustring-t('Actions')
placementWanted direction of the menustring-'bottom'
boundariesElementDOM element for the actions' popover boundariesElement-() => document.querySelector('body')
containerSelector for the actions' popover containerstring|object|Element|boolean-'body'
disabledDisabled state of the main button (single action or menu toggle)boolean-false
inlineDisplay x items inline out of the dropdown menu
Will be ignored if forceMenu is set
number-0

Events

Event namePropertiesDescription
update:openEvent emitted when the popover menu open state is changed
openEvent emitted when the popover menu is opened
closeEvent emitted when the popover menu is closed
focus
blur

Slots

NameDescriptionBindings
default
icon

Single action

vue
<template>
  <NcActions>
    <NcActionButton @click="actionDelete">
      <template #icon>
        <Delete :size="20" />
      </template>
      Delete
    </NcActionButton>
  </NcActions>
</template>
<script>
import Delete from "vue-material-design-icons/Delete";

export default {
  components: {
    Delete
  },
  methods: {
    actionDelete() {
      alert("Delete");
    }
  }
};
</script>

Multiple actions

vue
<template>
  <NcActions>
    <NcActionButton @click="showMessage('Edit')">
      <template #icon>
        <Pencil :size="20" />
      </template>
      Edit
    </NcActionButton>
    <NcActionButton @click="showMessage('Delete')">
      <template #icon>
        <Delete :size="20" />
      </template>
      Delete
    </NcActionButton>
    <NcActionLink href="https://nextcloud.com">
      <template #icon>
        <OpenInNew :size="20" />
      </template>
      Link
    </NcActionLink>
  </NcActions>
</template>
<script>
import Delete from "vue-material-design-icons/Delete";
import OpenInNew from "vue-material-design-icons/OpenInNew";
import Pencil from "vue-material-design-icons/Pencil";

export default {
  components: {
    Delete,
    OpenInNew,
    Pencil
  },
  methods: {
    showMessage(msg) {
      alert(msg);
    }
  }
};
</script>

Multiple actions with 2 items inline

<template>
	<NcActions :inline="2">
		<NcActionButton @click="showMessage('Add')">
			<template #icon>
				<Plus :size="20" />
			</template>
			Add
		</NcActionButton>
		<NcActionButton @click="showMessage('Edit')">
			<template #icon>
				<Pencil :size="20" />
			</template>
			Edit
		</NcActionButton>
		<NcActionButton @click="showMessage('Delete')">
			<template #icon>
				<Delete :size="20" />
			</template>
			Delete
		</NcActionButton>
		<NcActionLink href="https://nextcloud.com">
			<template #icon>
				<OpenInNew :size="20" />
			</template>
			Link
		</NcActionLink>
	</NcActions>
</template>
<script>
import Plus from 'vue-material-design-icons/Plus'
import Delete from 'vue-material-design-icons/Delete'
import OpenInNew from 'vue-material-design-icons/OpenInNew'
import Pencil from 'vue-material-design-icons/Pencil'

export default {
	components: {
		Delete,
		OpenInNew,
		Pencil,
		Plus,
	},
	methods: {
		showMessage(msg) {
			alert(msg)
		},
	},
}
</script>

Multiple actions with custom icon

<template>
	<NcActions>
		<template #icon>
			<Pencil :size="20" />
		</template>
		<NcActionButton @click="showMessage('Edit')">
			<template #icon>
				<Pencil :size="20" />
			</template>
			Edit
		</NcActionButton>
		<NcActionButton @click="showMessage('Delete')">
			<template #icon>
				<Delete :size="20" />
			</template>
			Delete
		</NcActionButton>
		<NcActionLink href="https://nextcloud.com">
			<template #icon>
				<OpenInNew :size="20" />
			</template>
			Link
		</NcActionLink>
	</NcActions>
</template>
<script>
import Delete from 'vue-material-design-icons/Delete'
import OpenInNew from 'vue-material-design-icons/OpenInNew'
import Pencil from 'vue-material-design-icons/Pencil'

export default {
	components: {
		Delete,
		OpenInNew,
		Pencil,
	},
	methods: {
		showMessage(msg) {
			alert(msg)
		},
	},
}
</script>

With menu title

<template>
	<NcActions menu-title="Object management">
		<template #icon>
			<Pencil :size="20" />
		</template>
		<NcActionButton>
			<template #icon>
				<Pencil :size="20" />
			</template>
			Rename
		</NcActionButton>
		<NcActionButton>
			<template #icon>
				<Delete :size="20" />
			</template>
			Delete
		</NcActionButton>
		<NcActionButton>
			<template #icon>
				<ArrowRight :size="20" />
			</template>
			Validate
		</NcActionButton>
		<NcActionButton>
			<template #icon>
				<Download :size="20" />
			</template>
			Download
		</NcActionButton>
	</NcActions>
</template>
<script>
import ArrowRight from 'vue-material-design-icons/ArrowRight'
import Delete from 'vue-material-design-icons/Delete'
import Download from 'vue-material-design-icons/Download'
import Pencil from 'vue-material-design-icons/Pencil'

export default {
	components: {
		ArrowRight,
		Delete,
		Download,
		Pencil,
	},
}
</script>

Various icons styles

<template>
	<NcActions :primary="true">
		<NcActionButton>
			<template #icon>
				<Pencil :size="20" />
			</template>
			Edit
		</NcActionButton>
		<NcActionButton>
			<template #icon>
				<Delete :size="20" />
			</template>
			Delete
		</NcActionButton>
	</NcActions>
</template>
<script>
import Delete from 'vue-material-design-icons/Delete'
import Pencil from 'vue-material-design-icons/Pencil'

export default {
	components: {
		Delete,
		Pencil,
	},
}
</script>
<template>
	<NcActions :primary="true" menu-title="Object management">
		<template #icon>
			<Plus :size="20" />
		</template>
		<NcActionButton>
			<template #icon>
				<Pencil :size="20" />
			</template>
			Rename
		</NcActionButton>
		<NcActionButton>
			<template #icon>
				<Delete :size="20" />
			</template>
			Delete
		</NcActionButton>
		<NcActionButton>
			<template #icon>
				<ArrowRight :size="20" />
			</template>
			Validate
		</NcActionButton>
		<NcActionButton>
			<template #icon>
				<Download :size="20" />
			</template>
			Download
		</NcActionButton>
	</NcActions>
</template>
<script>
import ArrowRight from 'vue-material-design-icons/ArrowRight'
import Delete from 'vue-material-design-icons/Delete'
import Download from 'vue-material-design-icons/Download'
import Pencil from 'vue-material-design-icons/Pencil'
import Plus from 'vue-material-design-icons/Plus'

export default {
	components: {
		ArrowRight,
		Delete,
		Download,
		Pencil,
		Plus,
	},
}
</script>

Custom icon slot

To be used with vue-material-design-icons only. For icon classes use the default-icon slot. It can be used with one or multiple actions.

<template>
	<div style="display: flex;align-items: center;">
		<NcButton @click="toggled = !toggled">Toggle multiple action</NcButton>
		<NcActions>
			<template #icon>
				<DotsHorizontalCircleOutline :size="20" />
			</template>
			<NcActionButton>
				<template #icon>
					<MicrophoneOff :size="20" />
				</template>
				Mute
			</NcActionButton>
			<NcActionButton v-if="toggled">
				<template #icon>
					<Delete :size="20" />
				</template>
				Delete
			</NcActionButton>
		</NcActions>
	</div>
</template>
<script>
import Delete from 'vue-material-design-icons/Delete'
import DotsHorizontalCircleOutline from 'vue-material-design-icons/DotsHorizontalCircleOutline'
import MicrophoneOff from 'vue-material-design-icons/MicrophoneOff'

export default {
	components: {
		Delete,
		DotsHorizontalCircleOutline,
		MicrophoneOff,
	},
	data() {
		return {
			toggled: false
		}
	}
}
</script>

Custom icon slot in child elements

<template>
	<NcActions :primary="true">
		<NcActionButton>
			<template #icon>
				<Magnify :size="20" />
			</template>
			Search
		</NcActionButton>
		<NcActionButton>
			<template #icon>
				<Delete :size="20" />
			</template>
			Delete
		</NcActionButton>
	</NcActions>
</template>
<script>
import Delete from 'vue-material-design-icons/Delete'
import Magnify from 'vue-material-design-icons/Magnify'

export default {
	components: {
		Delete,
		Magnify,
	},
}
</script>

Type variants

<template>
	<div>
		<NcActions :type="current">
			<template #icon>
				<SelectColor :size="20" />
			</template>

			<NcActionButton v-if="current" close-after-click @click="define(undefined)">
				<template #icon>
					<Delete :size="20" />
				</template>
				Remove
			</NcActionButton>

			<NcActionButton close-after-click @click="define(row)" v-for="row in types" :key="`type-icon--${row}`">
				<template #icon>
					<CheckboxMarkedCircleOutline v-if="row === current" :size="20" />
					<SelectColor v-else :size="20" />
				</template>
				{{ row }}
			</NcActionButton>
		</NcActions>

		<NcActions :type="current" menu-title="Choose a type">
			<NcActionButton v-if="current" close-after-click @click="define(undefined)">
				<template #icon>
					<Delete :size="20" />
				</template>
				Remove
			</NcActionButton>

			<NcActionButton close-after-click @click="define(row)" v-for="row in types" :key="`type-text--${row}`">
				<template #icon>
					<CheckboxMarkedCircleOutline v-if="row === current" :size="20" />
					<SelectColor v-else :size="20" />
				</template>
				{{ row }}
			</NcActionButton>
		</NcActions>

		<NcActions :type="current"  menu-title="Choose a type">
			<template #icon>
				<SelectColor :size="20" />
			</template>

			<NcActionButton v-if="current" close-after-click @click="define(undefined)">
				<template #icon>
					<Delete :size="20" />
				</template>
				Remove
			</NcActionButton>

			<NcActionButton close-after-click @click="define(row)" v-for="row in types" :key="`type-icon-text--${row}`">
				<template #icon>
					<CheckboxMarkedCircleOutline v-if="row === current" :size="20" />
					<SelectColor v-else :size="20" />
				</template>
				{{ row }}
			</NcActionButton>
		</NcActions>
	</div>
</template>

<script>
import Delete from 'vue-material-design-icons/Delete'
import Palette from 'vue-material-design-icons/Palette'
import SelectColor from 'vue-material-design-icons/SelectColor'
import CheckboxMarkedCircleOutline from 'vue-material-design-icons/CheckboxMarkedCircleOutline'

export default {
	components: {
		Delete,
		Palette,
		SelectColor,
		CheckboxMarkedCircleOutline,
	},
	data() {
		return {
			current: 'primary',
			types: [
				'primary',
				'secondary',
				'tertiary',
				'error',
				'warning',
				'success'
			]
		}
	},
	methods: {
		define(row) {
			this.current = row
		}
	}
}
</script>