Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

527
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda