diff --git a/ui/components/component-library/text/index.ts b/ui/components/component-library/text/index.ts
index 296bfc212d9c..0e4a6d9a9450 100644
--- a/ui/components/component-library/text/index.ts
+++ b/ui/components/component-library/text/index.ts
@@ -1,3 +1,3 @@
export { Text } from './text';
export { ValidTag, TextDirection, InvisibleCharacter } from './text.types';
-export type { TextProps } from './text.types';
+export type { TextProps, ValidTagType } from './text.types';
diff --git a/ui/components/component-library/text/text.test.tsx b/ui/components/component-library/text/text.test.tsx
index b34eb75d783e..1a22db8794cc 100644
--- a/ui/components/component-library/text/text.test.tsx
+++ b/ui/components/component-library/text/text.test.tsx
@@ -10,7 +10,7 @@ import {
TextVariant,
Color,
} from '../../../helpers/constants/design-system';
-import { TextDirection, ValidTag } from './text.types';
+import { TextDirection } from './text.types';
import { Text } from '.';
describe('Text', () => {
@@ -21,20 +21,20 @@ describe('Text', () => {
it('should render the Text with correct html elements', () => {
const { getByText, container } = render(
<>
- p
- h1
- h2
- h3
- h4
- h5
- h6
- span
- strong
- em
- li
- div
- dt
- dd
+ p
+ h1
+ h2
+ h3
+ h4
+ h5
+ h6
+ span
+ strong
+ em
+ li
+ div
+ dt
+ dd
>,
);
expect(container.querySelector('p')).toBeDefined();
diff --git a/ui/components/component-library/text/text.tsx b/ui/components/component-library/text/text.tsx
index 7ada78ffb3dd..3bd9b423e476 100644
--- a/ui/components/component-library/text/text.tsx
+++ b/ui/components/component-library/text/text.tsx
@@ -6,23 +6,23 @@ import {
TextVariant,
TextColor,
} from '../../../helpers/constants/design-system';
-import { TextProps, ValidTag } from './text.types';
+import { TextProps } from './text.types';
const getTextElementDefault = (variant: TextVariant) => {
switch (variant) {
case TextVariant.displayMd:
- return ValidTag.H1;
+ return 'h1';
case TextVariant.headingLg:
- return ValidTag.H2;
+ return 'h2';
case TextVariant.headingMd:
- return ValidTag.H3;
+ return 'h3';
case TextVariant.headingSm:
- return ValidTag.H4;
+ return 'h4';
case TextVariant.inherit:
- return ValidTag.Span;
+ return 'span';
// TextVariant.bodyLgMedium, TextVariant.bodyMd, TextVariant.bodyMdBold, TextVariant.bodySm, TextVariant.bodySmBold, TextVariant.bodyXs use default 'p' tag
default:
- return ValidTag.P;
+ return 'p';
}
};
diff --git a/ui/components/component-library/text/text.types.ts b/ui/components/component-library/text/text.types.ts
index 1f2e96bfe5cc..aef5b212c935 100644
--- a/ui/components/component-library/text/text.types.ts
+++ b/ui/components/component-library/text/text.types.ts
@@ -44,11 +44,31 @@ export enum ValidTag {
Header = 'header',
}
+export type ValidTagType =
+ | 'dd'
+ | 'div'
+ | 'dt'
+ | 'em'
+ | 'h1'
+ | 'h2'
+ | 'h3'
+ | 'h4'
+ | 'h5'
+ | 'h6'
+ | 'li'
+ | 'p'
+ | 'span'
+ | 'strong'
+ | 'ul'
+ | 'label'
+ | 'input'
+ | 'header';
+
export interface TextProps extends BoxProps {
/**
* The text content of the Text component
*/
- children: React.ReactNode;
+ children?: React.ReactNode;
/**
* The variation of font styles including sizes and weights of the Text component
* Possible values:
@@ -107,7 +127,7 @@ export interface TextProps extends BoxProps {
/**
* Changes the root html element tag of the Text component.
*/
- as?: ValidTag;
+ as?: ValidTagType;
/**
* Additional className to assign the Text component
*/