import { TagInput } from "@replicas/ui";

const tags = ["Design", "Marketing", "Finance", "Research", "Sales", "Support"];

export default function TagInputDemo() {
  return (
    <div style={{ width: 320 }}>
      <TagInput items={tags} defaultValue={["Design", "Research"]} placeholder="Add tags…" aria-label="Tags" />
    </div>
  );
}

Prompt

Copy Prompt hands your agent everything it needs to build the Tag Input in the Visitors style: the measured tokens, the CSS and the structure.

Show Prompt
# Visitors Tag Input

A field that collects several values as removable chips.

Build a Tag Input in this project that looks and behaves like Visitors's. Measured from the running Visitors app (visitors.now). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or Base UI primitives if it has none.

Fidelity: Derived from Visitors' input and referrer badge.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--background` | `#fff` | `#14141f` |
| `--fg-1` | `#b3b3b3` | `#73748c` |
| `--fg-2` | `#999` | `#9192a1` |
| `--fg-4` | `#181925` | `#eaeaeb` |
| `--bg-a2` | `#0000000d` | `#cccfff1a` |
| `--purple-2` | `#dad9fc` | `#080547` |
| `--purple-4` | `#918df6` | `#9580ff` |
| `--radius-4` | `0.5rem` | `0.5rem` |
| `--radius-5` | `0.75rem` | `0.75rem` |
| `--shadow-1` | `0px 1px 1px #00000014, 0px 0px 0px 1px #0000000d` | `0px 1px 1px #00000014, 0px 0px 0px 1px #0000000d` |
| `--input-bg` | `#f5f5f5` | `#212131` |
| `--input-text` | `#181925` | `#eaeaeb` |
| `--font-regular` | `"OpenRunde", "Open Runde", "Inter", sans-serif` | `"OpenRunde", "Open Runde", "Inter", sans-serif` |
| `--letter-spacing` | `-0.32px` | `-0.32px` |
| `--font-size-mini` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.875rem` | `0.875rem` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-rounded` | `9999px` | `9999px` |
| `--ease-in-out` | `cubic-bezier(0.4, 0, 0.2, 1)` | `cubic-bezier(0.4, 0, 0.2, 1)` |
| `--duration-fast` | `150ms` | `150ms` |

## CSS

Scoped under `[data-style="visitors"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.

```css
[data-style="visitors"] {
  .ui-tag-input {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 4px 6px;
    border-radius: var(--radius-5);
    background-color: var(--input-bg);
    color: var(--input-text);
    font-family: var(--font-regular);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
    letter-spacing: var(--letter-spacing);
    outline: 2px solid transparent;
    cursor: text;
    transition: all var(--duration-fast) var(--ease-in-out);

    &:focus-within {
      outline-color: var(--purple-4);
      box-shadow: 0 0 0 2px var(--purple-2);
    }
  }

  .ui-tag-input:is([data-size="sm"], [data-size="small"]) {
    min-height: 32px;
    padding: 2px 4px;
    border-radius: var(--radius-4);
  }

  .ui-tag-input-chips {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    min-width: 0;
  }

  .ui-tag-input-chip {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 28px;
    padding: 0 4px 0 10px;
    border-radius: var(--radius-rounded);
    background-color: var(--background);
    box-shadow: var(--shadow-1);
    color: var(--fg-4);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
    line-height: 20px;
    white-space: nowrap;
    outline: none;

    &:focus-visible,
    &[data-highlighted] {
      box-shadow:
        0 0 0 2px var(--purple-2),
        var(--shadow-1);
    }

    .ui-tag-input:is([data-size="sm"], [data-size="small"]) & {
      height: 24px;
      padding-left: 8px;
      font-size: var(--font-size-mini);
      line-height: 16px;
    }
  }

  .ui-tag-input-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-rounded);
    background-color: transparent;
    color: var(--fg-2);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-in-out);

    & svg {
      width: 14px;
      height: 14px;
    }

    @media (hover: hover) {
      &:hover {
        background-color: var(--bg-a2);
        color: var(--fg-4);
      }
    }
  }

  .ui-tag-input-input {
    box-sizing: border-box;
    flex: 1;
    min-width: 60px;
    height: 28px;
    margin: 0;
    padding: 0 10px;
    border: 0;
    background-color: transparent;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    outline: none;

    &::placeholder {
      color: var(--fg-1);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .ui-tag-input,
    .ui-tag-input-chip-remove {
      transition-duration: 0s;
    }
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Combobox as BaseCombobox } from "@base-ui/react/combobox";
import { Combobox } from "./combobox";
import { join } from "./utils";

export type TagInputProps = {
  items: string[];
  value?: string[];
  defaultValue?: string[];
  onValueChange?: (value: string[]) => void;
  placeholder?: string;
  emptyLabel?: string;
  size?: string;
  className?: string;
  "aria-label"?: string;
};

export function TagInput({
  items,
  value,
  defaultValue,
  onValueChange,
  placeholder,
  emptyLabel = "No results",
  size,
  className,
  "aria-label": ariaLabel,
}: TagInputProps) {
  return (
    <BaseCombobox.Root
      items={items}
      multiple
      value={value}
      defaultValue={defaultValue}
      onValueChange={onValueChange ? (next) => onValueChange(next as string[]) : undefined}
    >
      <BaseCombobox.InputGroup className={join("ui-tag-input", className)} data-size={size}>
        <BaseCombobox.Value>
          {(selected: string[]) => (
            <BaseCombobox.Chips className="ui-tag-input-chips" aria-label={selected.length > 0 ? "Selected" : undefined}>
              {selected.map((item) => (
                <BaseCombobox.Chip
                  key={item}
                  className="ui-tag-input-chip"
                  aria-description="Press Backspace or Delete to remove"
                >
                  <span className="ui-tag-input-chip-label">{item}</span>
                  <BaseCombobox.ChipRemove className="ui-tag-input-chip-remove" aria-label={`Remove ${item}`}>
                    <svg viewBox="0 0 16 16" fill="none" aria-hidden>
                      <path d="M5 5l6 6m0-6l-6 6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
                    </svg>
                  </BaseCombobox.ChipRemove>
                </BaseCombobox.Chip>
              ))}
              <BaseCombobox.Input
                className="ui-tag-input-input"
                aria-label={ariaLabel}
                placeholder={selected.length > 0 ? "" : placeholder}
              />
            </BaseCombobox.Chips>
          )}
        </BaseCombobox.Value>
      </BaseCombobox.InputGroup>
      <Combobox.Popup>
        <Combobox.Empty>{emptyLabel}</Combobox.Empty>
        <Combobox.List>
          {(item: string) => (
            <Combobox.Item key={item} value={item}>
              {item}
            </Combobox.Item>
          )}
        </Combobox.List>
      </Combobox.Popup>
    </BaseCombobox.Root>
  );
}
```

## Example

```tsx
import { TagInput } from "@replicas/ui";

const tags = ["Design", "Marketing", "Finance", "Research", "Sales", "Support"];

export default function TagInputDemo() {
  return (
    <div style={{ width: 320 }}>
      <TagInput items={tags} defaultValue={["Design", "Research"]} placeholder="Add tags…" aria-label="Tags" />
    </div>
  );
}
```

## Foundations

The rest of the Visitors style, as a skill: https://replicas.raphaelsalaja.com/skills/visitors/SKILL.md