Skip to content

ItemView

Official

A view that displays an item.

Import:

import { ItemView } from 'obsidian';

Signature:

export class ItemView extends View

Extends: View

Constructor

new ItemView(leaf: WorkspaceLeaf)

Constructor.

To extract the constructor type, use ExtractConstructor<ItemView>.

Properties

PropertyTypeDescription
actionsElHTMLElementContainer of actions for the view.
appAppThe Obsidian app instance.
(Inherited from View)
backButtonElHTMLButtonElementBack button element for changing view history.
canDropAnywherebooleanWhether the view may be dropped anywhere in workspace.
closeablebooleanWhether the leaf may close the view.
(Inherited from View)
containerElHTMLElementThe container HTML element for the component.
(Inherited from View)
contentElHTMLElementThe parent element of the content.
forwardButtonElHTMLButtonElementForward button element for changing view history.
headerElHTMLElementHeader bar container of view.
iconIconNameThe icon of the view.
(Inherited from View)
iconElHTMLElementIcon element for the view (for dragging).
leafWorkspaceLeafThe leaf of the view.
(Inherited from View)
leftSidebarToggleElHTMLElement | nullToggle button for the left sidebar, shown on mobile. null on desktop.
moreOptionsButtonElHTMLAnchorElementAnchor button for revealing more view actions.
navigationbooleanWhether or not the view is intended for navigation. If your view is a static view that is not intended to be navigated away, set this to false. (For example: File explorer, calendar, etc.) If your view opens a file or can be otherwise navigated, set this to true. (For example: Markdown editor view, Kanban view, PDF view, etc.)
(Inherited from View)
scopenull | ScopeAssign an optional scope to your view to register hotkeys for when the view is in focus.
(Inherited from View)
titleContainerElHTMLElementContainer for the title of the view.
titleElHTMLElementTitle element for the view.
titleParentElHTMLElementTitle of the parent.

Methods

MethodReturnsDescription
addAction(icon, title, callback)HTMLElementAdd an action to the item view.
close()Promise<void>Closes the view.
(Inherited from View)
getDisplayText()stringGet the display text of the view.
(Inherited from View)
getEphemeralState()Record<string, unknown>Get the ephemeral state of the view.
(Inherited from View)
getIcon()IconNameGet the icon of the view.
(Inherited from View)
getSideTooltipPlacement()'left' | 'right' | undefinedReturns the placement of the tooltip.
(Inherited from View)
getState()Record<string, unknown>Get the state of the view.
(Inherited from View)
getViewType()stringThe type of the view.
(Inherited from View)
handleCopy(event)voidHandle copy event on metadata editor and serialize properties.
(Inherited from View)
handleCut(event)voidHandle cut event on metadata editor and serialize and remove properties.
(Inherited from View)
handleDrop(event, draggable, isOver)DropResult | nullHandle a drop event on this view.
handlePaste(event)voidHandle paste event of properties on metadata editor.
(Inherited from View)
onClose()Promise<void>Called when the view is closed.
(Inherited from View)
onGroupChange()voidHandle a linked group change event.
onHeaderMenu(e)voidCalled when the header context menu is triggered.
(Inherited from View)
onMoreOptions(event)voidHandle the 'more options' button click event.
onMoreOptionsMenu(e)voidHandle the 'more options' context menu event.
onOpen()Promise<void>Called when the view is opened.
(Inherited from View)
onPaneMenu(menu, source)voidPopulates the pane menu.

(Replaces the previously removed onHeaderMenu and onMoreOptionsMenu)
(Inherited from View)
onResize()voidCalled when the size of this view is changed.
(Inherited from View)
onTabMenu(menu)voidAdds the menu items to the menu.
(Inherited from View)
open(parentEl)Promise<void>Opens the view.
(Inherited from View)
setEphemeralState(state)voidSet the ephemeral state of the view.
(Inherited from View)
setState(state, result)Promise<void>Set the state of the view.
(Inherited from View)
updateNavButtons()voidUpdate the state of the back/forward navigation buttons.

Links to this page: