CSS Click Dropdown Menu

A dropdown that opens on click or tap instead of hover, built on details and summary with no JavaScript.

  • dropdown
  • details
  • click
  • touch
  • actions menu
HTML
<details class="click-menu">
  <summary>Options</summary>
  <div class="click-menu-list">
    <a href="#">Edit</a>
    <a href="#">Duplicate</a>
    <a href="#">Archive</a>
    <a class="click-menu-danger" href="#">Delete</a>
  </div>
</details>
CSS
.click-menu {
  position: relative;
  display: inline-block;
  font: 500 14px system-ui, sans-serif;
}

.click-menu summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  color: #0f172a;
  list-style: none;
  cursor: pointer;
}

.click-menu summary::-webkit-details-marker {
  display: none;
}

.click-menu summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border: solid #64748b;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.click-menu[open] summary::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}

.click-menu summary:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.click-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10;
  display: grid;
  min-width: 160px;
  padding: 6px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 0 0 1px #0f172a14, 0 12px 28px -8px #0f172a40;
  transform-origin: top left;
  animation: click-menu-in 0.15s ease-out;
}

.click-menu-list a {
  padding: 8px 10px;
  border-radius: 8px;
  color: #334155;
  text-decoration: none;
}

.click-menu-list a:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.click-menu-list a:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.click-menu-list .click-menu-danger {
  margin-top: 4px;
  border-top: 1px solid #f1f5f9;
  border-radius: 0 0 8px 8px;
  color: #dc2626;
}

@keyframes click-menu-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .click-menu-list { animation: none; }
}

About this CSS Click Dropdown Menu

This CSS Click Dropdown Menu is 93 lines of pure CSS (1.7 KB) with no JavaScript and no dependencies. It uses keyframe animations, transitions, transforms and box shadows. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.

CSS features used

Customize it

The colors in this snippet. Search and replace them to match your brand:

  • #e2e8f0
  • #ffffff
  • #0f172a
  • #64748b
  • #2563eb
  • #0f172a14
  • #0f172a40
  • #334155
  • #f1f5f9
  • #dc2626

How to use this click dropdown menu

  1. Copy the HTML and paste it where you want the element to appear.
  2. Copy the CSS into your stylesheet, or inside a <style> tag.
  3. Keep the .click-menu class name, or rename it in both places. Then tweak colors, sizes and timing to match your design.
  4. Using React or Next.js? Change class to className in the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).

Building with an AI tool?

“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.

Feedback