Component

Select Group

Layout wrapper that groups multiple related selects with consistent spacing.

  • Component
  • React
  • TSX
  • Tailwind CSS
  • MIT

What it does

Capabilities

  • Semantic HTML
  • ARIA
  • Associated labels

Preview

Live component

Interactive preview
Open preview
9:41 100%
devsnips.site/library/react/components/selects/select-group/
fluid · no fixed width 100%
No dependencies Responsive · Light/dark · Focus-visible

Install

Add to your project

terminal
npx devsnips add React/Components/Selects/select-group
registry path: React/Components/Selects/select-group

Source

Implementation

code.tsx
import type { ReactNode } from "react";
import { useId } from "react";

export type SelectGroupDirection = "row" | "column";

export interface SelectGroupProps {
  label?: string;
  children: ReactNode;
  direction?: SelectGroupDirection;
  className?: string;
}

function cx(...parts: Array<string | false | null | undefined>): string {
  return parts.filter(Boolean).join(" ");
}

/**
 * Layout wrapper that arranges multiple related selects into a consistent
 * group. Renders a semantic <fieldset>/<legend> (the group label) and lays
 * its children out in a row (responsive grid) or column with a shared gap.
 * It does NOT reimplement the select itself — children are expected to be
 * select (or other field) components passed by the consumer.
 */
export function SelectGroup({
  label = "Group",
  children,
  direction = "column",
  className,
}: SelectGroupProps) {
  const generatedId = useId();
  const legendId = `select-group-${generatedId}-legend`;

  return (
    <fieldset
      aria-labelledby={legendId}
      className={cx(
        "min-w-0 rounded-[var(--ds-radius-md)] border border-[var(--ds-color-border)] bg-[var(--ds-color-surface)] p-4 motion-reduce:transition-none",
        className,
      )}
    >
      {label ? (
        <legend
          id={legendId}
          className="mb-3 px-1 text-[13px] font-medium leading-5 text-[var(--ds-color-foreground)]"
        >
          {label}
        </legend>
      ) : null}
      <div
        className={cx(
          direction === "row"
            ? "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3"
            : "flex flex-col gap-4",
        )}
      >
        {children}
      </div>
    </fieldset>
  );
}

export default SelectGroup;
62 lines UTF-8 · LF · Spaces: 2
DevSnips AI ready Claude · Cursor · Windsurf

Agent skill & Model Context Protocol

Pass this component straight into your AI workflow. DevSnips exposes each resource as a structured, addressable registry entry, so your agent installs the real files instead of approximating them.

devsnips://components/selects/select-group
Prompt instruction
I want to use this DevSnips resource in production:

Page:
https://devsnips.site/library/react/components/selects/select-group/

Install: npx devsnips add
React/Components/Selects/select-group

This is the Select Group — Layout wrapper that groups multiple related selects with consistent spacing.

Use this DevSnips resource as the starting point for my project.
Adapt it to my project's stack and conventions, fix any issues,
and make it production-ready while preserving its intended design
and behavior.

Paste into ChatGPT, Claude or your agent — it already carries the page URL and the exact install path.

Resource URI
devsnips://components/selects/select-group