Skip to content

useContentContainer

Introduction

TIP

Optionally, the component <ContentContainer> can also be used as a wrapper.

The composable useContentContainer() is used to map the depth of the page structure.

With each call of useContentContainer() in nested components, the level of the element structure is increased by one level.

The appropriate HTML element for the page structure is determined based on the level. (e.g. main, section, article)

vue
<template>
  <component v-if="currentTag" :is="currentTag">
    <slot />
  </component>
  <slot v-else />
</template>

<script setup>
import { useContentContainer } from 'vue-semantic-structure';

const { currentTag } = useContentContainer();
</script>

Options

PropertyTypeDescriptionDefault Value
tagStringCan be used to overwrite the tag.undefined
contentTagsArrayAvailable tags for the content structure.inject('semanticStructure_contentTags', ['article', 'section'])
rootTagsArrayAvailable tags for the root structure.inject('semanticStructure_rootTags', ['main'])
levelNumberCan be used to overwrite the level.undefined

Return

PropertyTypeDescription
currentTagStringGet current html tag.
parentLevelNumberGet parent level.
currentLevelNumberGet current level.