1 звезда на GitHub = 1 новый компонент.

Поставить звезду
Макеты и Сеткиlayoutflexspacing

Horizontal Cluster

Горизонтальный кластер для кнопок и меток с автоматическим переносом строк.

Живое превью

Horizontal Cluster

Использование

Скопируйте и вставьте этот код в ваш React-компонент:

tsx
import { ClusterHorizontal } from 'react-component-kit-ui/layout';

<ClusterHorizontal>Content</ClusterHorizontal>

Ручная установка

Если вы не используете пакет npm, создайте файл и вставьте следующий код: src/components/ClusterHorizontal.tsx + ClusterHorizontal.css:

ClusterHorizontal.tsx
'use client';

import type { CSSProperties, ReactNode } from 'react';
import './ClusterHorizontal.css';

/** "a: b; --c: d" → style object */
function st(css: string | undefined): CSSProperties {
  const o: Record<string, string> = {};
  for (const decl of String(css ?? '').split(';')) {
    const i = decl.indexOf(':');
    if (i < 0) continue;
    const k = decl.slice(0, i).trim();
    if (k) o[k.startsWith('--') ? k : k.replace(/-([a-z])/g, (_, c) => c.toUpperCase())] = decl.slice(i + 1).trim();
  }
  return o as CSSProperties;
}

/**
 * ClusterHorizontal — Auto-wrapping flex row for buttons, badges, or list items.
 */
export interface ClusterHorizontalProps {
  gap?: string;
  align?: 'flex-start' | 'center' | 'flex-end';
  className?: string;
  children?: ReactNode;
}

export function ClusterHorizontal({ gap = '0.75rem', align = 'center', className = '',
  children
}: ClusterHorizontalProps) {
  return (
    <>
      <div className={`cluster ${className}`} style={st(`--gap: ${gap}; --align: ${align};`)} data-rk-fff909="">
        {children ?? (<>
          <span className="cluster-tag" data-rk-fff909="">Tag 1</span>
          <span className="cluster-tag" data-rk-fff909="">Tag 2</span>
          <span className="cluster-tag" data-rk-fff909="">Tag 3</span>
          <span className="cluster-tag" data-rk-fff909="">Tag 4</span>
          <span className="cluster-tag" data-rk-fff909="">Tag 5</span>
        </>)}
      </div>
    </>
  );
}

export default ClusterHorizontal;
ClusterHorizontal.css
/* ClusterHorizontal — ported from astro-component-kit (layout/ClusterHorizontal.astro) */

.cluster:where([data-rk-fff909]) {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap, 0.75rem);
  align-items: var(--align, center);
  width: 100%;
}
.cluster-tag:where([data-rk-fff909]) {
  padding: 0.4rem 0.8rem;
  background: rgb(var(--ink-rgb, 255 255 255) / 0.05);
  border: 1px solid rgb(var(--ink-rgb, 255 255 255) / 0.1);
  border-radius: 9999px;
  font-size: 0.8rem;
  color: #94a3b8;
}

Краткая информация

Категория
Макеты и Сетки
Имя файла
ClusterHorizontal.tsx
Зависимости
Нет — чистый React + CSS
Теги
layoutflexspacing