React Native MantineNavigation

TableOfContents

List of links to page sections with depth offsets

Import: import { TableOfContents } from 'react-native-mantine';

Usage

import { TableOfContents } from 'react-native-mantine';

const data = [
  { id: 'introduction', value: 'Introduction', depth: 1 },
  { id: 'installation', value: 'Installation', depth: 2 },
  { id: 'usage', value: 'Usage', depth: 3 },
];

// Uncontrolled
<TableOfContents data={data} defaultActive="introduction" />

// Controlled, scroll to the pressed section
<TableOfContents
  data={data}
  active={active}
  onActiveChange={(id) => scrollToSection(id)}
  variant="filled"
  color="grape"
/>

Props

PropTypeDefaultDescription
data (required){ id: string; value: ReactNode; depth: number }[]Items to display
activestringControlled active item id
defaultActivestringInitial active item id for uncontrolled usage
onActiveChange(id: string) => voidCalled with the item id when a control is pressed
variant'filled' | 'light' | 'none'"light"Variant of the active control
colorMantineColorColor of the active control
size'xs' | 'sm' | 'md' | 'lg' | 'xl'"md"Controls font size and padding
radiusMantineNumberSize"sm"Border radius of controls
minDepthToOffsetnumber1Depth level that is rendered without offset
depthOffsetnumber20Offset in px applied for every depth level
getControlProps(payload: { active: boolean; data: TableOfContentsItem }) => Record<string, any>Additional props passed down to every control

Source on GitHub · npm