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

Property Type Description
actionsEl HTMLElement Container of actions for the view.
app App The Obsidian app instance.
(Inherited from View)
backButtonEl HTMLButtonElement Back button element for changing view history.
canDropAnywhere boolean Whether the view may be dropped anywhere in workspace.
closeable boolean Whether the leaf may close the view.
(Inherited from View)
containerEl HTMLElement The container HTML element for the component.
(Inherited from View)
contentEl HTMLElement The parent element of the content.
forwardButtonEl HTMLButtonElement Forward button element for changing view history.
headerEl HTMLElement Header bar container of view.
icon IconName The icon of the view.
(Inherited from View)
iconEl HTMLElement Icon element for the view (for dragging).
leaf WorkspaceLeaf The leaf of the view.
(Inherited from View)
leftSidebarToggleEl HTMLElement | null Toggle button for the left sidebar, shown on mobile. null on desktop.
moreOptionsButtonEl HTMLAnchorElement Anchor button for revealing more view actions.
navigation boolean Whether 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)
scope null | Scope Assign an optional scope to your view to register hotkeys for when the view is in focus.
(Inherited from View)
titleContainerEl HTMLElement Container for the title of the view.
titleEl HTMLElement Title element for the view.
titleParentEl HTMLElement Title of the parent.

Methods

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

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

Links to this page: