# Mobile filter bar

> A horizontally scrolling row of chips with faded edges and a fixed filter button carrying a badge.

- Category: [Filters](https://library.aimran.es/components/filters)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-f-mob-scroll
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

This is the pattern hotel and holiday apps use above their results: Nearby, Cheapest, Family, Pool, and more off to the side. The faded edges hint that the row keeps going, and the fixed button with a badge leads to the full filter panel. Search for it as a horizontal scrolling chip bar or mobile filter bar.

Put the most used filters first, since many people never scroll the row. The badge should count active filters from the full panel, so nobody forgets they have something switched on. Test it with a thumb, not a mouse.

## Code

### HTML

```html
<div class="uv-fms"><div class="ph"><div class="bar"><button class="fx"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 7h10M18 7h2M4 17h4M12 17h8"/><circle cx="16" cy="7" r="2"/><circle cx="10" cy="17" r="2"/></svg><span class="bd">2</span></button><div class="sc"><button class="on">All</button><button class="">Nearby</button><button class="">Top</button><button class="">New</button><button class="">Cheap</button><button class="">Family</button><button class="">Pool</button></div></div><div class="body"><span></span><span></span><span></span></div></div></div>
```

### CSS

```css
.uv-fms {
  --c1: #0071e3;
  --c2: #8ec5ff;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uv-fms {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}

.uv-fms .ph {
  position: relative;
  width: 16em;
  height: 26em;
  padding: .9em;
  border-radius: 2.2em;
  background: var(--bg);
  box-shadow: 0 0 0 2px color-mix(in srgb,var(--fg) 14%,transparent),0 24px 50px rgba(0,0,0,.18);
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.uv-fms .bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5em;
  padding: 1.4em .8em .8em;
  flex: 0 0 auto;
}

.uv-fms .fx {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  font-weight: 550;
  line-height: 1;
  padding: .72em 1.25em;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  color: var(--fg);
  position: relative;
  transition: color calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.32s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  display: inline-flex;
  align-items: center;
  padding: .6em;
  border-radius: .8em;
  background: var(--bg);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--fg) 14%,transparent);
  flex: 0 0 auto;
}

.uv-fms .fx svg {
  width: 1.15em;
  height: 1.15em;
}

.uv-fms .bd {
  position: absolute;
  top: -.3em;
  right: -.3em;
  display: grid;
  place-items: center;
  min-width: 1.25em;
  height: 1.25em;
  border-radius: 999px;
  font-size: calc(var(--s) * .62);
  font-weight: 700;
  color: #fff;
  background: var(--c1);
}

.uv-fms .sc {
  display: flex;
  gap: .4em;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask: linear-gradient(90deg,transparent,#000 6%,#000 88%,transparent);
}

.uv-fms .sc::-webkit-scrollbar {
  display: none;
}

.uv-fms .sc button {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  font-weight: 550;
  line-height: 1;
  padding: .72em 1.25em;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  color: var(--fg);
  position: relative;
  transition: color calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.32s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  flex: 0 0 auto;
  font-size: calc(var(--s) * .85);
  padding: .6em 1em;
  background: color-mix(in srgb,var(--fg) 7%,transparent);
}

.uv-fms .sc button.on {
  color: #fff;
  background: var(--c1);
  box-shadow: 0 6px 14px color-mix(in srgb,var(--c1) 32%,transparent);
}

.uv-fms .body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .7em;
  padding: .4em .8em;
}

.uv-fms .body span {
  height: 4em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}
```

### JavaScript

```js
document.querySelectorAll(".uv-fms").forEach(el => {
  el.querySelectorAll(".sc button").forEach(b=>b.addEventListener("click",()=>{el.querySelectorAll(".sc button").forEach(x=>x.classList.remove("on"));b.classList.add("on");b.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})}))
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uv-fms {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}

.uv-fms .ph {
  position: relative;
  width: 16em;
  height: 26em;
  padding: .9em;
  border-radius: 2.2em;
  background: var(--bg);
  box-shadow: 0 0 0 2px color-mix(in srgb,var(--fg) 14%,transparent),0 24px 50px rgba(0,0,0,.18);
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.uv-fms .bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5em;
  padding: 1.4em .8em .8em;
  flex: 0 0 auto;
}

.uv-fms .fx {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  font-weight: 550;
  line-height: 1;
  padding: .72em 1.25em;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  color: var(--fg);
  position: relative;
  transition: color calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.32s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  display: inline-flex;
  align-items: center;
  padding: .6em;
  border-radius: .8em;
  background: var(--bg);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--fg) 14%,transparent);
  flex: 0 0 auto;
}

.uv-fms .fx svg {
  width: 1.15em;
  height: 1.15em;
}

.uv-fms .bd {
  position: absolute;
  top: -.3em;
  right: -.3em;
  display: grid;
  place-items: center;
  min-width: 1.25em;
  height: 1.25em;
  border-radius: 999px;
  font-size: calc(var(--s) * .62);
  font-weight: 700;
  color: #fff;
  background: var(--c1);
}

.uv-fms .sc {
  display: flex;
  gap: .4em;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask: linear-gradient(90deg,transparent,#000 6%,#000 88%,transparent);
}

.uv-fms .sc::-webkit-scrollbar {
  display: none;
}

.uv-fms .sc button {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  font-weight: 550;
  line-height: 1;
  padding: .72em 1.25em;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  color: var(--fg);
  position: relative;
  transition: color calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.32s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  flex: 0 0 auto;
  font-size: calc(var(--s) * .85);
  padding: .6em 1em;
  background: color-mix(in srgb,var(--fg) 7%,transparent);
}

.uv-fms .sc button.on {
  color: #fff;
  background: var(--c1);
  box-shadow: 0 6px 14px color-mix(in srgb,var(--c1) 32%,transparent);
}

.uv-fms .body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .7em;
  padding: .4em .8em;
}

.uv-fms .body span {
  height: 4em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  el.querySelectorAll(".sc button").forEach(b=>b.addEventListener("click",()=>{el.querySelectorAll(".sc button").forEach(x=>x.classList.remove("on"));b.classList.add("on");b.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})}))
}

export default function FMobScroll() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uv-fms"><div className="ph"><div className="bar"><button className="fx"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round"><path d="M4 7h10M18 7h2M4 17h4M12 17h8" /><circle cx="16" cy="7" r="2" /><circle cx="10" cy="17" r="2" /></svg><span className="bd">2</span></button><div className="sc"><button className="on">All</button><button className="">Nearby</button><button className="">Top</button><button className="">New</button><button className="">Cheap</button><button className="">Family</button><button className="">Pool</button></div></div><div className="body"><span></span><span></span><span></span></div></div></div>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Mobile filter bar” block (Filters) from AIMRAN Library to my project.

## What it is
A horizontally scrolling row of chips with faded edges and a fixed filter button carrying a badge.

## Chosen settings
- Main color: #0071e3
- Secondary color: #8ec5ff
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uv-fms {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
}

.uv-fms .ph {
  position: relative;
  width: 16em;
  height: 26em;
  padding: .9em;
  border-radius: 2.2em;
  background: var(--bg);
  box-shadow: 0 0 0 2px color-mix(in srgb,var(--fg) 14%,transparent),0 24px 50px rgba(0,0,0,.18);
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.uv-fms .bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5em;
  padding: 1.4em .8em .8em;
  flex: 0 0 auto;
}

.uv-fms .fx {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  font-weight: 550;
  line-height: 1;
  padding: .72em 1.25em;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  color: var(--fg);
  position: relative;
  transition: color calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.32s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  display: inline-flex;
  align-items: center;
  padding: .6em;
  border-radius: .8em;
  background: var(--bg);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--fg) 14%,transparent);
  flex: 0 0 auto;
}

.uv-fms .fx svg {
  width: 1.15em;
  height: 1.15em;
}

.uv-fms .bd {
  position: absolute;
  top: -.3em;
  right: -.3em;
  display: grid;
  place-items: center;
  min-width: 1.25em;
  height: 1.25em;
  border-radius: 999px;
  font-size: calc(var(--s) * .62);
  font-weight: 700;
  color: #fff;
  background: var(--c1);
}

.uv-fms .sc {
  display: flex;
  gap: .4em;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask: linear-gradient(90deg,transparent,#000 6%,#000 88%,transparent);
}

.uv-fms .sc::-webkit-scrollbar {
  display: none;
}

.uv-fms .sc button {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  font-weight: 550;
  line-height: 1;
  padding: .72em 1.25em;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: transparent;
  color: var(--fg);
  position: relative;
  transition: color calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.32s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.32s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  flex: 0 0 auto;
  font-size: calc(var(--s) * .85);
  padding: .6em 1em;
  background: color-mix(in srgb,var(--fg) 7%,transparent);
}

.uv-fms .sc button.on {
  color: #fff;
  background: var(--c1);
  box-shadow: 0 6px 14px color-mix(in srgb,var(--c1) 32%,transparent);
}

.uv-fms .body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .7em;
  padding: .4em .8em;
}

.uv-fms .body span {
  height: 4em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  el.querySelectorAll(".sc button").forEach(b=>b.addEventListener("click",()=>{el.querySelectorAll(".sc button").forEach(x=>x.classList.remove("on"));b.classList.add("on");b.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})}))
}

export default function FMobScroll() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uv-fms"><div className="ph"><div className="bar"><button className="fx"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round"><path d="M4 7h10M18 7h2M4 17h4M12 17h8" /><circle cx="16" cy="7" r="2" /><circle cx="10" cy="17" r="2" /></svg><span className="bd">2</span></button><div className="sc"><button className="on">All</button><button className="">Nearby</button><button className="">Top</button><button className="">New</button><button className="">Cheap</button><button className="">Family</button><button className="">Pool</button></div></div><div className="body"><span></span><span></span><span></span></div></div></div>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
