diff --git a/packages/components/src/components/columns/columns.stories.tsx b/packages/components/src/components/columns/columns.stories.tsx
index 81bd2519..83d4f35e 100644
--- a/packages/components/src/components/columns/columns.stories.tsx
+++ b/packages/components/src/components/columns/columns.stories.tsx
@@ -60,6 +60,24 @@ export const FourColumns: Story = {
args: { cols: 4 },
};
+/**
+ * When placed inside a container query context, columns respond to the
+ * container width instead of the viewport width.
+ *
+ * Resize the container below to see the columns respond to the container width.
+ */
+export const InsideContainer: StoryObj = {
+ render: () => (
+
+
+ 1
+ 2
+ 3
+
+
+ ),
+};
+
export const WithCustomClassName: Story = {
args: {
cols: 2,
diff --git a/packages/components/src/components/columns/columns.tsx b/packages/components/src/components/columns/columns.tsx
index 911c2d19..d9b63581 100644
--- a/packages/components/src/components/columns/columns.tsx
+++ b/packages/components/src/components/columns/columns.tsx
@@ -2,6 +2,7 @@ import type React from "react";
import { Classes } from "@/constants/selectors";
import { cn } from "@/utils/cn";
import type { ColCount } from "./constants";
+import { DEFAULT_COLS } from "./constants";
type ColumnsProps = {
children: React.ReactNode;
@@ -9,18 +10,23 @@ type ColumnsProps = {
className?: string;
};
-const Columns = ({ children, className, cols = 2 }: ColumnsProps) => {
+const Columns = ({
+ children,
+ className,
+ cols = DEFAULT_COLS,
+}: ColumnsProps) => {
+ const numCols = Number(cols) || DEFAULT_COLS;
+
return (
{children}
diff --git a/packages/components/src/components/columns/constants.ts b/packages/components/src/components/columns/constants.ts
index 6a603b35..187ac29d 100644
--- a/packages/components/src/components/columns/constants.ts
+++ b/packages/components/src/components/columns/constants.ts
@@ -1,5 +1,8 @@
const COL_OPTIONS = [1, 2, 3, 4] as const;
type ColCount = (typeof COL_OPTIONS)[number];
-export { COL_OPTIONS };
+const DEFAULT_COLS = 2;
+
+export { COL_OPTIONS, DEFAULT_COLS };
+
export type { ColCount };