0
0
Tailwindmarkup~20 mins

Component library patterns (Headless UI) in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Headless UI Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the main advantage of using Headless UI components?
Headless UI components provide unstyled, accessible UI primitives. What is the biggest benefit of this approach?
AThey restrict customization to maintain uniform design.
BThey come with built-in styles that cannot be changed.
CThey allow developers to fully control styling while ensuring accessibility.
DThey automatically generate CSS styles for you.
Attempts:
2 left
💡 Hint
Think about how Headless UI separates logic from style.
📝 Syntax
intermediate
1:30remaining
Which Tailwind class correctly applies a responsive grid layout?
You want a grid with 1 column on small screens and 3 columns on medium and larger screens. Which class string achieves this?
Agrid-cols-1 grid md:grid-cols-3 gap-4
Bgrid grid-cols-1 md:grid-cols-3 gap-4
Cgrid grid-cols-3 md:grid-cols-1 gap-4
Dgrid-cols-3 grid grid-cols-1 md:gap-4
Attempts:
2 left
💡 Hint
Remember Tailwind uses mobile-first approach and responsive prefixes like md:
rendering
advanced
2:00remaining
What will be the visible result of this Headless UI Menu component snippet?
Consider this React code using Headless UI Menu and Tailwind CSS:
import { Menu } from '@headlessui/react';

export default function Example() {
  return (
    
      Options
      
        
          {({ active }) => (
            Account
          )}
        
        
          {({ active }) => (
            Settings
          )}
        
      
    
  );
}
ATwo buttons labeled 'Account' and 'Settings' always visible below a gray 'Options' label.
BA blue button labeled 'Options' with no dropdown menu visible or interactive.
CA white button labeled 'Options' that shows a blue dropdown with two links in gray text.
DA blue button labeled 'Options' that toggles a white dropdown with two links: 'Account' and 'Settings'. Hovering a link highlights it blue with white text.
Attempts:
2 left
💡 Hint
Headless UI Menu.Button toggles Menu.Items visibility with styling applied.
selector
advanced
1:30remaining
Which Tailwind selector targets only the focused state of a Headless UI button?
You want to style a Headless UI button only when it is focused (keyboard or programmatically). Which Tailwind class applies this style correctly?
Afocus:outline-none focus:ring-2 focus:ring-blue-500
Bhover:outline-none hover:ring-2 hover:ring-blue-500
Cactive:outline-none active:ring-2 active:ring-blue-500
Dvisited:outline-none visited:ring-2 visited:ring-blue-500
Attempts:
2 left
💡 Hint
Focus styles apply when the element is focused, not hovered or active.
accessibility
expert
2:00remaining
What ARIA role does Headless UI assign to its Dialog component by default?
Headless UI Dialog component manages accessibility automatically. Which ARIA role is assigned to the main dialog container?
Adialog
Balertdialog
Cregion
Dcomplementary
Attempts:
2 left
💡 Hint
Dialogs usually have a specific ARIA role to identify them as modal windows.