Rows n’ Columns Docs
Visit HomepagePricing
  • Introduction
  • License
  • Demos
  • Getting started
    • Installation
    • Spreadsheet state
    • Headless UI
    • Imperative Spreadsheet API
    • Examples
  • ⚙️Configuration
    • Features
      • Data validation
      • Formula evaluation
      • Real-time data
      • Cell editors
      • Cell renderer
      • Structured Cell Renderer
      • Theming
      • Styling
      • Context menu
      • Localisation
      • Undo/Redo
      • Conditional formatting
      • Named ranges
      • Structured references
        • Schema based tables and columns
        • Calculated columns
      • Basic filter or Excel AutoFilter
      • Charts
      • Embedded content
      • Calculate on-demand
      • Drag and Drop
      • Pivoting and Grouping (Coming soon)
      • Tokenizer
      • Lazy loading/Infinite scrolling
      • OpenAI/Chat GPT Integration
      • Search
      • Formula protection
      • Autofill
      • Export canvas as image
    • Components
      • Canvas Grid
      • Toolbar
      • Sheet Tabs
      • Sheet Switcher
      • Sheet Status
      • Range Selector
      • Formula Input
      • Selection Input
      • SheetSearch
      • NamedRangeEditor
      • DeleteSheetConfirmation
      • TableEditor
      • Cell Format Editor
      • Conditional Format Editor
      • Data Validation Editor
      • Insert Link Editor
      • Insert Image Editor
    • API
      • Cell Data
      • Sheets
      • SpreadsheetProvider
      • useSpreadsheet
      • Modules
      • SheetCell
    • Using Spreadsheet with NextJS
    • Keyboard shortcuts
  • Collaboration
    • Real time collaboration
    • Yjs Collaboration
    • Supabase realtime Collaboration
  • Charts
    • Charts
    • Custom charts
  • Excel and Google sheets
    • CSV
    • Excel
    • Google sheets (Coming soon)
  • Functions
    • Named functions
    • Array formulas
  • Data persistence
    • Server side data persistence
    • React Query integration
  • Specifications
    • Browser support
    • Third party licenses
  • Support
    • Contact support
    • Report bugs
    • Feature requests
Powered by GitBook
On this page

Was this helpful?

  1. Configuration
  2. Components

Sheet Tabs

Quickly switch between multiple sheets

PreviousToolbarNextSheet Switcher

Last updated 1 year ago

Was this helpful?

Optional SheetTab component to select sheets, and change sheet attributes. You can choose to use your preferred Tab component

import { SheetTabs } from "@rowsncolumns/spreadsheet"

const App = () => {
  return (
    <SheetTabs
      sheets={sheets}
      activeSheetId={activeSheetId}
      onChangeActiveSheet={onChangeActiveSheet}
      onRenameSheet={onRenameSheet}
      onChangeSheetTabColor={onChangeSheetTabColor}
      onDeleteSheet={onRequestDeleteSheet}
      onHideSheet={onHideSheet}
      onMoveSheet={onMoveSheet}
      onProtectSheet={onProtectSheet}
      onUnProtectSheet={onUnProtectSheet}
      onDuplicateSheet={onDuplicateSheet}
    />
  )
}

Custom context menu

Each sheet tab can display a custom context menu. Use the ContextMenu props to inject a react component

You can use the default menu as a template to build your own Context menu

https://github.com/rowsncolumns/spreadsheet/blob/main/apps/spreadsheet/components/sheet-tabs/context-menu.tsx

Contextmenu uses shadcn/radix-ui dropdown components internally.

import type { SheetTabContextMenuProps } from "@rowsncolumns/spreadsheet"
import {
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuPortal,
  DropdownMenuSeparator,
  DropdownMenuSub,
  DropdownMenuSubContent,
  DropdownMenuSubTrigger,
  DropdownRightSlot,
} from "@rowsncolumns/ui";

const CustomContextMenu = ({ onDeleteSheet, canDelete, sheetId }: SheetTabContextMenuProps) => {
  return (
    <DropdownMenuPortal>
      <DropdownMenuContent align="start">
        <DropdownMenuItem
          onClick={() => onDeleteSheet?.(sheetId)}
          disabled={!canDelete}
        >
          Delete
        </DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenuPortal>
  )
}
<SheetTabs ContextMenu={CustomContextMenu}>
⚙️
Sheet tabs