FontSize extension
This extension enables you to set the font size in the editor. It uses the TextStyle mark, which renders a <span> tag. The font size is applied as inline style, for example <span style="font-size: 14px">.
Install
npm install @tiptap/extension-text-styleThis extension requires the TextStyle mark.
import { Editor } from '@tiptap/core'
import { TextStyle, FontSize } from '@tiptap/extension-text-style'
new Editor({
extensions: [TextStyle, FontSize],
})This extension is installed by default with the TextStyleKit extension, so you don’t need to install it separately.
import { Editor } from '@tiptap/core'
import { TextStyleKit } from '@tiptap/extension-text-style'
new Editor({
extensions: [TextStyleKit],
})Settings
types
A list of marks to which the font family attribute should be applied to.
Default: ['textStyle']
FontSize.configure({
types: ['textStyle'],
})Commands
setFontSize()
Applies the given font family as inline style.
editor.commands.setFontSize('14px')unsetFontSize()
Removes any font family.
editor.commands.unsetFontSize()Source code
packages/extension-text-style/src/font-size/
Minimal Install
import { Editor } from '@tiptap/core'
import { FontSize } from '@tiptap/extension-text-style/font-size'
new Editor({
extensions: [FontSize],
})