Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.
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/grumpy-cycles-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': minor
---

Deprecated `DisplayText`, `Heading`, `Subheading`, `Caption`, `TextStyle`, and `VisuallyHidden` components
5 changes: 5 additions & 0 deletions .changeset/grumpy-donuts-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'polaris.shopify.com': minor
---

Deprecated `DisplayText`, `Heading`, `Subheading`, `Caption`, `TextStyle`, and `VisuallyHidden` pages and removed examples
12 changes: 7 additions & 5 deletions polaris-react/playground/DetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
import {
ActionList,
Badge,
Caption,
Card,
ContextualSaveBar,
DropZone,
Expand All @@ -36,12 +35,12 @@ import {
SkeletonDisplayText,
SkeletonPage,
Stack,
Text,
TextContainer,
TextField,
Thumbnail,
Toast,
TopBar,
VisuallyHidden,
} from '../src';

import styles from './DetailsPage.scss';
Expand Down Expand Up @@ -451,7 +450,7 @@ export function DetailsPage() {
const loadingMarkup = isLoading ? <Loading /> : null;

const skipToContentTarget = (
<VisuallyHidden>
<Text as="span" variant="bodySm" visuallyHidden>
<a
href="#SkipToContent"
id="SkipToContentTarget"
Expand All @@ -460,7 +459,7 @@ export function DetailsPage() {
>
Page content
</a>
</VisuallyHidden>
</Text>
);

const [title, setTitle] = useState(
Expand Down Expand Up @@ -534,7 +533,10 @@ export function DetailsPage() {
}
/>
<div>
{file.name} <Caption>{file.size} bytes</Caption>
{file.name}{' '}
<Text as="p" variant="bodySm">
{file.size} bytes
</Text>
</div>
</Stack>
))}
Expand Down
14 changes: 14 additions & 0 deletions polaris-react/src/components/Caption/Caption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ export interface CaptionProps {
children?: React.ReactNode;
}

/**
* @deprecated The Caption component will be removed in the next
* major version. Use the Text component instead. See the
* Polaris component guide on how to use Text.
*
* https://polaris.shopify.com/components/text
*/
export function Caption({children}: CaptionProps) {
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.warn(
'Deprecation: The `Caption` component has been deprecated. Use the `Text` component instead. See the Polaris component guide on how to use `Text`. https://polaris.shopify.com/components/text',
);
}

return <p className={styles.Caption}>{children}</p>;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import {mountWithApp} from 'tests/utilities';

// eslint-disable-next-line import/no-deprecated
import {Caption} from '../Caption';

describe('<Caption />', () => {
Expand Down
14 changes: 14 additions & 0 deletions polaris-react/src/components/DisplayText/DisplayText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export interface DisplayTextProps {
children?: React.ReactNode;
}

/**
* @deprecated The DisplayText component will be removed in the next
* major version. Use the Text component instead. See the
* Polaris component guide on how to use Text.
*
* https://polaris.shopify.com/components/text
*/
export function DisplayText({
element: Element = 'p',
children,
Expand All @@ -32,5 +39,12 @@ export function DisplayText({
size && styles[variationName('size', size)],
);

if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.warn(
'Deprecation: The `DisplayText` component has been deprecated. Use the `Text` component instead. See the Polaris component guide on how to use `Text`. https://polaris.shopify.com/components/text',
);
}

return <Element className={className}>{children}</Element>;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import {mountWithApp} from 'tests/utilities';

// eslint-disable-next-line import/no-deprecated
import {DisplayText} from '../DisplayText';

describe('<DisplayText />', () => {
Expand Down
14 changes: 14 additions & 0 deletions polaris-react/src/components/Heading/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ export interface HeadingProps {
id?: string;
}

/**
* @deprecated The Heading component will be removed in the next
* major version. Use the Text component instead. See the
* Polaris component guide on how to use Text.
*
* https://polaris.shopify.com/components/text
*/
export function Heading({element: Element = 'h2', children, id}: HeadingProps) {
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.warn(
'Deprecation: The `Heading` component has been deprecated. Use the `Text` component instead. See the Polaris component guide on how to use `Text`. https://polaris.shopify.com/components/text',
);
}

return (
<Element className={styles.Heading} id={id}>
{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import {mountWithApp} from 'tests/utilities';

// eslint-disable-next-line import/no-deprecated
import {Heading} from '../Heading';

describe('<Heading />', () => {
Expand Down
16 changes: 15 additions & 1 deletion polaris-react/src/components/Subheading/Subheading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,26 @@ export interface SubheadingProps {
/** Text to display in subheading */
children?: React.ReactNode;
}

/**
* @deprecated The Subheading component will be removed in the next
* major version. Use the Text component instead. See the
* Polaris component guide on how to use Text.
*
* https://polaris.shopify.com/components/text
*/
export function Subheading({
element: Element = 'h3',
children,
}: SubheadingProps) {
const ariaLabel = typeof children === 'string' ? children : undefined;

if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.warn(
'Deprecation: The `Subheading` component has been deprecated. Use the `Text` component instead. See the Polaris component guide on how to use `Text`. https://polaris.shopify.com/components/text',
);
}

return (
<Element aria-label={ariaLabel} className={styles.Subheading}>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import {mountWithApp} from 'tests/utilities';

import {Button} from '../../Button';
// eslint-disable-next-line import/no-deprecated
import {Subheading} from '../Subheading';

describe('<Subheading />', () => {
Expand Down
2 changes: 1 addition & 1 deletion polaris-react/src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import React, {
} from 'react';
import {CircleCancelMinor} from '@shopify/polaris-icons';

import {Text} from '../Text';
import {classNames, variationName} from '../../utilities/css';
import {useI18n} from '../../utilities/i18n';
import {useUniqueId} from '../../utilities/unique-id';
Expand All @@ -16,6 +15,7 @@ import {Labelled, LabelledProps, helpTextID, labelID} from '../Labelled';
import {Connected} from '../Connected';
import {Error, Key} from '../../types';
import {Icon} from '../Icon';
import {Text} from '../Text';

import {Resizer, Spinner, SpinnerProps} from './components';
import styles from './TextField.scss';
Expand Down
15 changes: 15 additions & 0 deletions polaris-react/src/components/TextStyle/TextStyle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,26 @@ export interface TextStyleProps {
children?: React.ReactNode;
}

/**
* @deprecated The TextStyle component will be removed in the next
* major version. Use the Text component instead. See the
* Polaris component guide on how to use Text.
*
* https://polaris.shopify.com/components/text
*/
export function TextStyle({variation, children}: TextStyleProps) {
const className = classNames(
variation && styles[variationName('variation', variation)],
variation === VariationValue.Code && styles.code,
);

if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.warn(
'Deprecation: The `TextStyle` component has been deprecated. Use the `Text` component instead. See the Polaris component guide on how to use `Text`. https://polaris.shopify.com/components/text',
);
}

const Element = variationElement(variation);

return <Element className={className}>{children}</Element>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import {mountWithApp} from 'tests/utilities';

// eslint-disable-next-line import/no-deprecated
import {TextStyle} from '../TextStyle';

describe('<TextStyle />', () => {
Expand Down
14 changes: 14 additions & 0 deletions polaris-react/src/components/VisuallyHidden/VisuallyHidden.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ export interface VisuallyHiddenProps {
children?: React.ReactNode;
}

/**
* @deprecated The VisuallyHidden component will be removed in the next
* major version. Use the Text component instead. See the
* Polaris component guide on how to use Text.
*
* https://polaris.shopify.com/components/text
*/
export function VisuallyHidden({children}: VisuallyHiddenProps) {
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.warn(
'Deprecation: The VisuallyHidden` component has been deprecated. Use the `Text` component instead. See the Polaris component guide on how to use `Text`. https://polaris.shopify.com/components/text',
);
}

return <span className={styles.VisuallyHidden}>{children}</span>;
}
16 changes: 12 additions & 4 deletions polaris.shopify.com/content/components/caption.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ keywords:
- time text
- compact text
- small text
examples:
- fileName: caption-default.tsx
title: Default
description: Use to provide details in situations where content is compact and space is tight.
status:
value: Deprecated
message: This component is no longer supported. Please use the Text component instead.
---

## Mapping to the Text component

```diff
- <Caption>Received April 21, 2017</Caption>
+ <Text variant="bodySm" as="p">Received April 21, 2017</Text>
```

---

## Best practices
Expand Down
48 changes: 35 additions & 13 deletions polaris.shopify.com/content/components/display-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,41 @@ keywords:
- visual story telling
- visual storytelling
- visual statements
examples:
- fileName: display-text-extra-large.tsx
title: Extra large
description: Use this size sparingly and never multiple times on the same page.
- fileName: display-text-large.tsx
title: Large
description: Use for display text that’s more important than the medium size, but less important than extra large.
- fileName: display-text-medium.tsx
title: Medium
description: Use for display text that’s more important than the small size, but less important than large.
- fileName: display-text-small.tsx
title: Small
description: Use for text that would otherwise use body text, but that needs to scale with other display text.
status:
value: Deprecated
message: This component is no longer supported. Please use the Text component instead.
---

## Mapping to the Text component

### Small

```diff
- <DisplayText size="small">Sales this year</DisplayText>
+ <Text variant="headingLg" as="p">Sales this year</Text>
```

### Medium

```diff
- <DisplayText size="medium">Sales this year</DisplayText>
+ <Text variant="headingXl" as="p">Sales this year</Text>
```

### Large

```diff
- <DisplayText size="large">Sales this year</DisplayText>
+ <Text variant="heading2xl" as="p">Sales this year</Text>
```

### Extra large

```diff
- <DisplayText size="extraLarge">Sales this year</DisplayText>
+ <Text variant="heading4xl" as="p">Sales this year</Text>
```

---

## Best practices
Expand Down
16 changes: 12 additions & 4 deletions polaris.shopify.com/content/components/heading.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ keywords:
- section headings
- heading text
- heading font
examples:
- fileName: heading-default.tsx
title: Default
description: Use for the title of each top-level page section.
status:
value: Deprecated
message: This component is no longer supported. Please use the Text component instead.
---

## Mapping to the Text component

```diff
- <Heading>Online store dashboard</Heading>
+ <Text variant="headingMd" as="h2">Online store dashboard</Text>
```

---

## Best practices
Expand Down
16 changes: 12 additions & 4 deletions polaris.shopify.com/content/components/subheading.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ keywords:
- titles of sub-sections
- subsection titles
- titles of subsections
examples:
- fileName: subheading-default.tsx
title: Default
description: Used for the title of any sub-sections in top-level page sections.
status:
value: Deprecated
message: This component is no longer supported. Please use the Text component instead.
---

## Mapping to the Text component

```diff
- <Subheading>Accounts</Subheading>
+ <Text variant="headingXs" as="h3">Accounts</Text>
```

---

## Best practices
Expand Down
Loading