Skip to main content

MultiSelect

Multiple options with a beautiful search input.

Package@g4rcez/componentsSectionForm Controls

Examples

Basic MultiSelect

A multi-select component demonstrating selection of multiple programming languages. The selected values are displayed below.

Programming Languages

Selected: []

tsx
"use client";
import { useState, useEffect } from "react";
import { Card, MultiSelect } from "@g4rcez/components";

const defaults = [
  { label: "C#", value: "csharp" },
  { label: "Elixir", value: "elixir" },
  { label: "JavaScript", value: "javascript" },
  { label: "TypeScript", value: "typescript" },
  { label: "Python", value: "python" },
];

function BasicMultiSelect() {
  const [options, setOptions] = useState([]);
  const [value, setValue] = useState<string[]>([]);

  useEffect(() => {
    setOptions(defaults);
  }, []);

  return (
    <Card>
      <MultiSelect
        id="basic-multiselect"
        required
        options={options}
        title="Programming Languages"
        placeholder="Select your languages"
        onChangeOptions={setValue}
      />
      <div className="mt-4">
        <p>Selected: {JSON.stringify(value)}</p>
      </div>
    </Card>
  );
}

Empty MultiSelect

Demonstrates the multi-select component when no options are available.

Empty Options
tsx
"use client";
import { Card, MultiSelect } from "@g4rcez/components";

function EmptyMultiSelect() {
  const [value, setValue] = useState<string[]>([]);
  return (
    <Card>
      <MultiSelect
        id="empty-multiselect"
        required
        options={[]}
        title="Empty Options"
        onChangeOptions={setValue}
        placeholder="No options to select"
      />
    </Card>
  );
}

Field Sizes

Use size=normal or size=small to control the density of the trigger, tags, and search field.

Sizes
tsx
import { MultiSelect } from "@g4rcez/components";

function MultiSelectSizes() {
  return (
    <div className="grid grid-cols-1 gap-6 md:grid-cols-2">
      <MultiSelect size="normal" title="Normal multi-select" options={defaults} placeholder="Choose your languages" />
      <MultiSelect size="small" title="Small multi-select" options={defaults} placeholder="Choose your languages" />
    </div>
  );
}

When to use MultiSelect

Use when

You need the documented MultiSelect interaction or presentation in a product workflow.

Avoid when

A native HTML element already provides the MultiSelect behavior you need.

Accessibility

Keep the MultiSelect labeled and use its documented keyboard interaction. The component preserves visible focus and communicates state without relying on color alone.

  • Keep keyboard focus visible and follow the documented key commands.
  • Provide an accessible name and connect descriptions or errors to the control.