Text Editor - Subscript

Toggle subscript formatting on the current selection with the subscript command and pressed state.

#Usage

import { TextEditor } from '@primeui/vue-texteditor';
<TextEditor.Root v-model="value">
    <TextEditor.Toolbar>
        <SubscriptButton />
    </TextEditor.Toolbar>
    <TextEditor.Content />
</TextEditor.Root>

Subscript lowers text below the baseline for formulas or footnote marks. A toolbar button toggles the mark on the selection with commands.subscript() and reflects pressed state with state.subscript, both from useTextEditorContext().

#Command

commands.subscript() toggles the mark on the selected text. Subscript and superscript are mutually exclusive, so applying subscript over a superscript run clears the superscript.

<!-- SubscriptButton.vue -->
<script setup lang="ts">
import { useTextEditorContext } from '@primeui/vue-texteditor';

const { commands, state } = useTextEditorContext();
</script>

<template>
    <button @click="commands.subscript()" :aria-pressed="state.subscript">x₂</button>
</template>

#Example

Loading Demo...

#API

commands.subscript() and state.subscript come from useTextEditorContext(). See API for the full reference.