Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cyan-months-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
---

Added `id` prop to `Text` and `Box`
4 changes: 4 additions & 0 deletions polaris-react/src/components/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export interface BoxProps {
children: ReactNode;
/** Color of children */
color?: ColorTokenScale;
/** HTML id attribute */
id?: string;
/** Spacing outside of container */
maxWidth?: string;
/** Spacing around children */
Expand Down Expand Up @@ -122,6 +124,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
borderRadiusTopRight,
children,
color,
id,
maxWidth,
padding,
paddingBottom,
Expand Down Expand Up @@ -218,6 +221,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
as,
{
className,
id,
ref,
style: sanitizeCustomProperties(style),
},
Expand Down
9 changes: 8 additions & 1 deletion polaris-react/src/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export interface TextProps {
color?: Color;
/** Adjust weight of text */
fontWeight?: FontWeight;
/** HTML id attribute */
id?: string;
/** Truncate text overflow with ellipsis */
truncate?: boolean;
/** Typographic style of text */
Expand All @@ -64,6 +66,7 @@ export const Text = ({
children,
color,
fontWeight,
id,
truncate = false,
variant,
visuallyHidden = false,
Expand All @@ -81,5 +84,9 @@ export const Text = ({
visuallyHidden && styles.visuallyHidden,
);

return <Component className={className}>{children}</Component>;
return (
<Component className={className} {...(id ? id : null)}>
{children}
</Component>
);
};