Group

A recessed container that holds a set of cards. Padding and gap are the same value, and the corner radius is concentric with the cards inside it.

src/components/ui/group.tsx

About

From the component's own source, where it was written.

A recessed container that holds a set of cards.

The padding and the gap are the same value at every size, so the space between two cards matches the space between a card and the container edge.

The radius is concentric: the group's corner is the card's corner plus the padding between them (--radius-group-* in index.css). Reusing the card's own radius would make the gap between the two curves pinch at the corners.

A horizontal group stacks below responsive — three cards side by side on a phone gives each of them about a hundred pixels, which is not a layout.

Install

npx astralyx-ui add group

Usage

import { Group } from '@/components/ui/group'
import { Card, CardBody } from '@/components/ui/card'

<Group>
  <Card><CardBody>Notifications</CardBody></Card>
  <Card><CardBody>Appearance</CardBody></Card>
</Group>

Composer

Change the props and the source below follows.

Notifications

Email me when a build finishes.

Appearance

Follow the system colour scheme.

Telemetry

Share anonymous usage data.

Props
tsx
<Group>
  <Card>
    <CardBody>Notifications</CardBody>
  </Card>
  <Card>
    <CardBody>Appearance</CardBody>
  </Card>
</Group>

Examples

Vertical

Horizontal and even

Sizes

With a header card

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

Group

A recessed container that holds a set of cards.

Extends ComponentProps<'div'>.

PropTypeDefaultDescription
size'sm' | 'default' | 'lg''default'Padding and gap together — 12, 18 or 24px. Each size also picks the matching concentric radius.
orientation'horizontal' | 'vertical''vertical'Stack the cards or lay them in a row. Horizontal wraps.
evenbooleanfalseGive every child an equal share of the main axis. Mostly for horizontal groups.
responsiveResponsive'sm'Breakpoint a horizontal group becomes a row at. Below it the cards stack, so a row of three never squeezes into thirds of a phone screen. false keeps it a row at every width.
radius--radius-group-*—Card radius plus the group padding, so the gap between the two curves stays even into the corners. Tunable in index.css.

Functions

FunctionSignatureDescription
groupVariants(props?: { orientation?: 'horizontal' | 'vertical'; size?: 'sm' | 'default' | 'lg'; even?: boolean }) => stringA recessed container that holds a set of cards.