Font Size

Adds toolbar and context buttons for inline font size. Applies font-size as a <span> style on the selected text, or maps sizes to CSS classes when classes is set.

Select text, click Text size in the toolbar (before More), and pick a size from the dropdown. Use Remove text size to clear formatting.

Load the bundle

<script src="/assets/redactor/redactor.js"></script>
<script src="/assets/redactor/plugins/font-size/font-size.js"></script>

Initialization

const app = Redactor('#entry', {
    plugins: ['fontSize']
});

Options

  • items (string[] | false)
    • default false
    • Font sizes shown in the dropdown. false uses the built-in list: 10px through 30px (see FontSizePlugin.DEFAULT_SIZES).
  • classes (string[] | false)
    • default false
    • When set to a non-empty array, switches to class-based mode. Each entry is a CSS class name applied to a <span> instead of an inline font-size style.
  • icon (string)
    • SVG icon HTML for the toolbar and context buttons.
Redactor('#entry', {
    plugins: ['fontSize'],
    fontSize: {
        items: ['12px', '14px', '16px', '18px', '24px']
    }
});

Language strings

en: {
    fontSize: {
        title: 'Text size',
        remove: 'Remove text size'
    }
}

Events

This plugin does not emit events.

API

set

Applies font size formatting to the current selection and closes the dropdown. Pass the same params object used by app.inline.set.

app.fontSize.set({ tag: 'span', styles: { 'font-size': '20px' } });

remove

Clears inline font size (or size classes in class mode) from the selection and closes the dropdown.

app.fontSize.remove();