Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a split button dropdown container.
Bootsrap
<div class="btn-group"> <button type="button" class="btn btn-primary">Action</button> <button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-bs-toggle="[1]" aria-expanded="false"> <span class="visually-hidden">Toggle Dropdown</span> </button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Option 1</a></li> <li><a class="dropdown-item" href="#">Option 2</a></li> </ul> </div>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using data-bs-toggle="modal" instead of "dropdown"
Forgetting the dropdown-toggle-split class
Not including aria-expanded attribute
✗ Incorrect
The attribute data-bs-toggle="dropdown" tells Bootstrap to toggle the dropdown menu when the split button is clicked.
2fill in blank
mediumComplete the code to add a dropdown item that is disabled.
Bootsrap
<ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Active Item</a></li> <li><a class="dropdown-item [1]" href="#" tabindex="-1" aria-disabled="true">Disabled Item</a></li> </ul>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using class "active" instead of "disabled"
Omitting tabindex="-1" for disabled items
Not setting aria-disabled="true" for accessibility
✗ Incorrect
Adding the class "disabled" along with tabindex="-1" and aria-disabled="true" makes the dropdown item disabled and inaccessible by keyboard.
3fill in blank
hardFix the error in the split button dropdown toggle button to ensure accessibility.
Bootsrap
<button type="button" class="btn btn-secondary dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" [1]> <span class="visually-hidden">Toggle Dropdown</span> </button>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using aria-pressed instead of aria-expanded
Omitting aria-expanded attribute
Using aria-haspopup without aria-expanded
✗ Incorrect
The attribute aria-expanded="false" indicates the dropdown is initially closed, improving screen reader accessibility.
4fill in blank
hardFill both blanks to create a split button dropdown with a primary button and a secondary toggle button.
Bootsrap
<div class="btn-group"> <button type="button" class="btn btn-[1]">Primary Action</button> <button type="button" class="btn btn-[2] dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false"> <span class="visually-hidden">Toggle Dropdown</span> </button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Item 1</a></li> <li><a class="dropdown-item" href="#">Item 2</a></li> </ul> </div>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same style for both buttons
Using 'danger' or 'success' for the toggle button
Forgetting the dropdown-toggle-split class
✗ Incorrect
The main button uses the 'primary' style, and the toggle button uses the 'secondary' style for visual distinction.
5fill in blank
hardFill all three blanks to create a split button dropdown with uppercase label, value binding, and a condition to show only enabled items.
Bootsrap
const dropdownItems = items.filter(item => item.[3]).map(item => ({ label: item.[1].toUpperCase(), value: item.[2] }));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'title' instead of 'name' for label
Filtering by 'id' instead of 'enabled'
Using 'name' as value instead of 'id'
✗ Incorrect
We filter items by 'enabled' property, convert 'name' to uppercase for label, and use 'id' as the value.