Skip to content

SectionGrid item size huge with one or two items #172

Description

@bradleyburgess

Describe the bug or issue

If there are only one or two items inside SectionGrid, the items expand to fill the entire available space because of auto-fit. I don't believe this is the desired effect, as if there is one item it is gigantic.

I updated my local SectionGrid to use auto-fill instead of auto-fit, and I believe this is a more desirable result.

// src/components/ui/section/section-grid.astro

const variants = cva("grid w-full gap-6", {
  variants: {
    frame: {
      default: "",
    },
    size: {
      sm: "grid-cols-[repeat(auto-fill,minmax(200px,1fr))]",
      default: "grid-cols-1 sm:grid-cols-[repeat(auto-fill,minmax(260px,1fr))]",
      lg: "grid-cols-1 sm:grid-cols-[repeat(auto-fill,minmax(400px,1fr))]",
      xl: "grid-cols-1 sm:grid-cols-[repeat(auto-fill,minmax(600px,1fr))]",
    },
  },
  defaultVariants: {
    size: "default",
    frame: "default",
  },
});

This way, if there is one item, it won't grow to fit the entire available width; it will remain contained inside, not growing beyond the max size declared with minmax.

Happy to do a PR if this is agreeable.


Before (currently, with auto-fit):
Image

After (with auto-fill):
Image

For context, the layout with more items:
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions