CSS Inline Sort Select

A borderless "Sort by" select that reads like part of the sentence, for product lists and search results.

  • sort by
  • select
  • inline
  • filter
  • toolbar
  • minimal
HTML
<label class="sort-by">
  Sort by
  <select name="sort">
    <option>Newest</option>
    <option>Price: low to high</option>
    <option>Price: high to low</option>
    <option>Best rated</option>
  </select>
</label>
CSS
.sort-by {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #71717a;
  font: 14px system-ui, sans-serif;
}

.sort-by select {
  padding: 4px 22px 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2318181b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 4px center / 12px;
  color: #18181b;
  font: 600 14px system-ui, sans-serif;
  -webkit-appearance: none;
  appearance: none;
  field-sizing: content;
  cursor: pointer;
}

.sort-by select:hover {
  background-color: #f4f4f5;
}

.sort-by select:focus-visible {
  outline: 2px solid #18181b;
  outline-offset: 1px;
}

About this CSS Inline Sort Select

This CSS Inline Sort Select is 29 lines of pure CSS (0.8 KB) with no JavaScript and no dependencies. It uses field-sizing, Flexbox and keyboard focus styles. It relies on field-sizing, which not every browser supports yet, so check the browser notes below. 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:

  • #71717a
  • #18181b
  • #f4f4f5

How to use this inline sort select

  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 .sort-by 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