diff --git a/.changeset/unlucky-carrots-shop.md b/.changeset/unlucky-carrots-shop.md
new file mode 100644
index 000000000..31e08c690
--- /dev/null
+++ b/.changeset/unlucky-carrots-shop.md
@@ -0,0 +1,9 @@
+---
+"@localyze-pluto/components": minor
+---
+
+[Select] Add width properties so it's easier to set width for the SelectPopover:
+
+- `sameWidth` to make the popover the same width as the select
+- `popoverMaxWidth` to set a max width for the popover
+- `popoverWidth` to set a fixed width for the popover
diff --git a/packages/components/src/components/Select/Select.stories.tsx b/packages/components/src/components/Select/Select.stories.tsx
index addae92b7..87f99d45e 100644
--- a/packages/components/src/components/Select/Select.stories.tsx
+++ b/packages/components/src/components/Select/Select.stories.tsx
@@ -65,6 +65,61 @@ export const Default = (): JSX.Element => {
);
};
+export const SameWidth = (): JSX.Element => {
+ const selectID = useUID();
+ const helpTextID = useUID();
+ return (
+
+
+
+ Please choose one of the values.
+
+ );
+};
+
+export const CustomWidth = (): JSX.Element => {
+ const selectID = useUID();
+ const helpTextID = useUID();
+ return (
+
+
+
+ Please choose one of the values.
+
+ );
+};
+
+export const WithMaxWidth = (): JSX.Element => {
+ const selectID = useUID();
+ const helpTextID = useUID();
+ return (
+
+
+
+ Please choose one of the values.
+
+ );
+};
+
export const Large = (): JSX.Element => {
const selectID = useUID();
const helpTextID = useUID();
diff --git a/packages/components/src/components/Select/Select.tsx b/packages/components/src/components/Select/Select.tsx
index 0cfb54577..f1b6908b2 100644
--- a/packages/components/src/components/Select/Select.tsx
+++ b/packages/components/src/components/Select/Select.tsx
@@ -10,7 +10,7 @@ import {
import type { SelectProps as SelectPrimitiveProps } from "@ariakit/react/select";
import type { SystemProp, Theme } from "@xstyled/styled-components";
import isArray from "lodash/isArray";
-import { Box } from "../../primitives/Box";
+import { Box, BoxProps } from "../../primitives/Box";
import { Text } from "../../primitives/Text";
import { Icon } from "../Icon";
import { SelectItem } from "./SelectItem";
@@ -59,6 +59,12 @@ export interface SelectProps
size?: "large" | "small";
/** The selected option of the select. */
value?: string[] | string;
+ /** The width of the select popover. */
+ popoverWidth?: BoxProps["w"];
+ /** The max width of the select popover. */
+ popoverMaxWidth?: BoxProps["maxW"];
+ /** Sets the select popover to be the same width as the select. */
+ sameWidth?: boolean;
}
const getSelectStyles = (
@@ -140,6 +146,9 @@ const Select = React.forwardRef(
setValue,
size = "small",
value,
+ sameWidth,
+ popoverWidth,
+ popoverMaxWidth,
...props
},
ref,
@@ -231,7 +240,14 @@ const Select = React.forwardRef(
/>
-
+
{map(items, (item) => (
{
/** The valid contents of the listbox, i.e. SelectItem. */
children: NonNullable;
+ w?: BoxProps["w"];
+ maxW?: BoxProps["maxW"];
}
/** A select popover is a styled dropdown element that contains a list of select options. */
const SelectPopover = React.forwardRef(
- ({ children, store, gutter, sameWidth, ...props }, ref) => {
+ ({ children, store, gutter, sameWidth, w, maxW, ...props }, ref) => {
return (
(
flexDirection="column"
gutter={gutter}
maxHeight="250px"
+ maxW={maxW}
outlineColor={{ focus: "colorBorderPrimary" }}
outlineStyle={{ focus: "solid" }}
outlineWidth={{ focus: "borderWidth10" }}
@@ -33,6 +36,7 @@ const SelectPopover = React.forwardRef(
ref={ref}
sameWidth={sameWidth}
store={store}
+ w={w}
zIndex="zIndex50"
{...props}
>