user29441535
user29441535

Reputation: 1

Unnecessary space on top of toolbar Items

I am using QuillJs. There is some unnecessary space on top of toolbar icons.

Here's what it looks like

Here's what it looks like when I inspect element on my browser.

Image 1

Image 2

What am I doing wrong?

I've tried removing the space by altering the margins, paddings, heights, but it doesn't work.

var toolbarOptions = [
    ['bold', 'italic', 'underline'], // Basic text styles
    [{ 'list': 'ordered' }, { 'list': 'bullet' }], // Lists
    ['link'], // Allow hyperlinks
];      

var quillLongIntro = new Quill('#longIntroduction', {
    theme: 'snow',
    modules: { toolbar: toolbarOptions }
});
.ql-editor {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    background-color: var(--white);
    border: 1px solid var(--gray);
    border-radius: 8px;
    
}

.ql-container {
    border-radius: 8px;
    margin-top: 0;
}

.ql-toolbar{
    margin: 0px !important;
    padding-top: 0px !important;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-radius: 8px;
    min-height: 35px;
    height: auto;
}

.ql-toolbar .ql-formats {
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

.ql-toolbar:empty{
    display:none;
}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/quill.js"></script>
<div id="longIntroduction"></div>

Upvotes: -1

Views: 35

Answers (1)

vishal bhuva
vishal bhuva

Reputation: 7

Add the following CSS fixes to properly align toolbar items:




   /* Ensure toolbar has no extra padding/margin */
.ql-toolbar {
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-radius: 8px;
    min-height: 35px;
    height: auto;
}

/* Remove unwanted padding/margin from toolbar buttons */
.ql-toolbar button,
.ql-toolbar .ql-picker-label {
    margin: 0 !important;
    padding: 4px !important; /* Adjust padding */
    height: 30px !important; /* Ensure uniform height */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure toolbar icons are aligned properly */
.ql-toolbar .ql-formats {
    display: flex !important;
    align-items: center !important;
    gap: 4px; /* Add spacing between buttons */
    margin: 0 !important;
    padding: 0 !important;
}

/* Fix height issues in the editor */
.ql-container {
    border-radius: 8px;
    margin-top: 0 !important;
}

.ql-editor {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    background-color: var(--white);
    border: 1px solid var(--gray);
    border-radius: 8px;
    padding: 10px !important; /* Ensure consistent spacing */
}

/* Hide toolbar when it's empty */
.ql-toolbar:empty {
    display: none;
}

Upvotes: -1

Related Questions