# Travel search bar

> Where, dates and guests in one rounded bar, with the section you tap lifting out as a pill.

- Category: [Inputs](https://library.aimran.es/components/inputs)
- Built with: React + Motion
- Live editor: https://library.aimran.es/blocks/travel-search
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

This is the search bar pattern people know from booking sites: destination, dates and number of guests side by side, then a round search button. It fits a holiday rental site, a small hotel chain, a campsite or a tour company. If you need a travel booking search bar in React, it gives you the layout and the feel.

The fields here are placeholders, so connect each one to your own date picker or guest selector. Change the search button to your brand color. On narrow screens the sections wrap onto new lines, which is worth checking with your real labels.

## Code

### React (Motion)

```tsx
import { useState } from "react";
import { motion } from "framer-motion";
import { CalendarDays, MapPin, Search, Users } from "lucide-react";

const spring = { type: "spring" as const, stiffness: 300, damping: 30 };

const items = [
  { Icon: MapPin, label: "Where", hint: "Search destinations" },
  { Icon: CalendarDays, label: "Dates", hint: "Add dates" },
  { Icon: Users, label: "Guests", hint: "Add guests" },
] as const;

interface TravelSearchProps {
  color?: string;
  onSearch?: () => void;
}

export default function TravelSearch({ color = "#0071e3", onSearch }: TravelSearchProps) {
  const [active, setActive] = useState(0);

  return (
    <motion.div
      layout
      transition={spring}
      className="flex w-full max-w-[440px] flex-wrap items-center rounded-[28px] bg-white p-1.5 text-[#1d1d1f] shadow-[0_1px_2px_rgba(0,0,0,0.03),0_8px_28px_rgba(0,0,0,0.05)] dark:bg-[#1c1c1e] dark:text-[#f5f5f7]"
    >
      {items.map(({ Icon, label, hint }, i) => (
        <motion.button
          layout
          key={label}
          type="button"
          aria-pressed={active === i}
          onClick={() => setActive(i)}
          className={`flex min-w-28 flex-1 items-center gap-2 rounded-full px-4 py-3 text-left ${
            active === i
              ? "bg-[#f5f5f7] shadow-[0_1px_2px_rgba(0,0,0,0.03),0_8px_28px_rgba(0,0,0,0.05)] dark:bg-black"
              : ""
          }`}
        >
          <Icon className="h-4 w-4" />
          <span>
            <b className="block text-xs font-medium">{label}</b>
            <small className="block text-[11px] text-[#86868b]">{hint}</small>
          </span>
        </motion.button>
      ))}
      <button
        type="button"
        aria-label="Search"
        onClick={onSearch}
        className="grid h-11 w-11 place-items-center rounded-full text-white"
        style={{ backgroundColor: color }}
      >
        <Search className="h-4 w-4" />
      </button>
    </motion.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 “Travel search bar” block (Inputs) from AIMRAN Library to my project.

## What it is
Where, dates and guests in one rounded bar, with the section you tap lifting out as a pill.

## Chosen settings
- Color: #0071e3

## 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 React + TypeScript, with framer-motion for the animation and lucide-react for the icons. 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
import { useState } from "react";
import { motion } from "framer-motion";
import { CalendarDays, MapPin, Search, Users } from "lucide-react";

const spring = { type: "spring" as const, stiffness: 300, damping: 30 };

const items = [
  { Icon: MapPin, label: "Where", hint: "Search destinations" },
  { Icon: CalendarDays, label: "Dates", hint: "Add dates" },
  { Icon: Users, label: "Guests", hint: "Add guests" },
] as const;

interface TravelSearchProps {
  color?: string;
  onSearch?: () => void;
}

export default function TravelSearch({ color = "#0071e3", onSearch }: TravelSearchProps) {
  const [active, setActive] = useState(0);

  return (
    <motion.div
      layout
      transition={spring}
      className="flex w-full max-w-[440px] flex-wrap items-center rounded-[28px] bg-white p-1.5 text-[#1d1d1f] shadow-[0_1px_2px_rgba(0,0,0,0.03),0_8px_28px_rgba(0,0,0,0.05)] dark:bg-[#1c1c1e] dark:text-[#f5f5f7]"
    >
      {items.map(({ Icon, label, hint }, i) => (
        <motion.button
          layout
          key={label}
          type="button"
          aria-pressed={active === i}
          onClick={() => setActive(i)}
          className={`flex min-w-28 flex-1 items-center gap-2 rounded-full px-4 py-3 text-left ${
            active === i
              ? "bg-[#f5f5f7] shadow-[0_1px_2px_rgba(0,0,0,0.03),0_8px_28px_rgba(0,0,0,0.05)] dark:bg-black"
              : ""
          }`}
        >
          <Icon className="h-4 w-4" />
          <span>
            <b className="block text-xs font-medium">{label}</b>
            <small className="block text-[11px] text-[#86868b]">{hint}</small>
          </span>
        </motion.button>
      ))}
      <button
        type="button"
        aria-label="Search"
        onClick={onSearch}
        className="grid h-11 w-11 place-items-center rounded-full text-white"
        style={{ backgroundColor: color }}
      >
        <Search className="h-4 w-4" />
      </button>
    </motion.div>
  );
}
```

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