Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

526
Vistas
How to use the default font size selector with custom Quill toolbar?

The normal/default Quill editor uses this kind of size editor:

Picture of the quill.js editor's size dropdown

I am building a custom toolbar using the tools provided by Quill. That looks like this:

        const toolbarOptions = [
            [
                { font: ['Lato,sans-serif'] },
            ],
            ['size'],
            ['bold', 'italic', 'underline'],
            ['link'],
            ['clean'],
        ];

['size'] is invalid syntax, as nothing shows on the toolbar if you use that:

enter image description here

If I alter the 'size' array to be [{ size: ['10px', '12px' ... }] etc, the dropdown ends up looking like this:

custom quilljs dropdown with the word 'normal' for all sizes

How can I use the default size that comes with the editor in a custom configuration of options?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can override the editor's CSS to change the content of the labels and font sizes. The custom style will take precedence when added after the stylesheet. I left the default values commented in the snippet below.

const toolbarOptions = [
    [
        { font: ['Lato,sans-serif'] },
    ],
    [{ 'size': ['small', false, 'large', 'huge'] }],

    ['bold', 'italic', 'underline'],
    ['link'],
    ['clean'],
];

const quill = new Quill('#editor', {
    theme: 'snow',
    modules: {
        toolbar: toolbarOptions
    }
});
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">

<style>
 .ql-container {
    box-sizing: border-box;
    font-family: Helvetica, Arial, sans-serif;
    /* font-size: 13px; */
    font-size: 12px;
    height: 100%;
    margin: 0px;
    position: relative;
  }

  .ql-editor .ql-size-small {
    /* font-size: 0.75em; */
    font-size: 10px;
  }

  .ql-editor .ql-size-large {
    /* font-size: 1.5em; */
    font-size: 14px;
  }

  .ql-editor .ql-size-huge {
    /* font-size: 2.5em; */
    font-size: 16px;
  }

  .ql-snow .ql-picker.ql-size .ql-picker-label::before,
  .ql-snow .ql-picker.ql-size .ql-picker-item::before {
    /* content: 'Normal'; */
    content: '12px';
  }

  .ql-snow .ql-picker.ql-size .ql-picker-label[data-value=small]::before,
  .ql-snow .ql-picker.ql-size .ql-picker-item[data-value=small]::before {
    /* content: 'Small'; */
    content: '10px';
  }

  .ql-snow .ql-picker.ql-size .ql-picker-label[data-value=large]::before,
  .ql-snow .ql-picker.ql-size .ql-picker-item[data-value=large]::before {
    /* content: 'Large'; */
    content: '14px';
  }

  .ql-snow .ql-picker.ql-size .ql-picker-label[data-value=huge]::before,
  .ql-snow .ql-picker.ql-size .ql-picker-item[data-value=huge]::before {
    /* content: 'Huge'; */
    content: '16px';
  }

  .ql-snow .ql-picker.ql-size .ql-picker-item[data-value=small]::before {
    font-size: 10px;
  }

  .ql-snow .ql-picker.ql-size .ql-picker-item[data-value=large]::before {
    /* font-size: 18px; */
    font-size: 14px;
  }

  .ql-snow .ql-picker.ql-size .ql-picker-item[data-value=huge]::before {
    /* font-size: 32px; */
    font-size: 16px;
  }
</style>

<div id="editor">
  <p>Hello World!</p>
  <p>Some initial <strong>bold</strong> text</p>
  <p><br></p>
</div>

<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda