diff --git a/packages/react/src/hooks/useTheme.tsx b/packages/react/src/hooks/useTheme.tsx
index c291868889..c23109dd51 100644
--- a/packages/react/src/hooks/useTheme.tsx
+++ b/packages/react/src/hooks/useTheme.tsx
@@ -12,13 +12,14 @@ const setComponentTheme = (selector: string, theme: T, customClass: string):
if (typeof window === 'undefined') return;
// checks if the given css rule contains the custom class selector
- const hasCustomRule = (rule: CSSRule): boolean => rule.cssText.includes(`${selector}.${customClass}`);
+ const hasCustomRule = (rule: CSSStyleRule): boolean => rule.selectorText?.includes(`${selector}.${customClass}`);
try {
const { styleSheets } = document;
// the index of the parent stylesheet
const parentIndex = [...styleSheets].findIndex(
- (styleSheet) => [...styleSheet.cssRules].findIndex((rule) => rule.cssText.includes(selector)) >= 0,
+ (styleSheet) =>
+ [...styleSheet.cssRules].findIndex((rule: CSSStyleRule) => rule.selectorText?.includes(selector)) >= 0,
);
// style sheet containing the css rules for the selector
const parentStyleSheet = styleSheets[parentIndex];
diff --git a/packages/react/src/internal/selectedItems/SelectedItems.tsx b/packages/react/src/internal/selectedItems/SelectedItems.tsx
index 6fb5567545..f46eb39638 100644
--- a/packages/react/src/internal/selectedItems/SelectedItems.tsx
+++ b/packages/react/src/internal/selectedItems/SelectedItems.tsx
@@ -222,7 +222,6 @@ export const SelectedItems = ({
key={selectedItemLabel}
className={styles.tag}
id={tagId}
- label={selectedItemLabel}
labelProps={{ 'aria-labelledby': `${dropdownId}-label ${tagId}-label` }}
deleteButtonAriaLabel={replaceTokenWithValue(removeButtonAriaLabel, selectedItemLabel)}
// remove delete button from focus order
@@ -243,7 +242,9 @@ export const SelectedItems = ({
},
onFocus: () => setActiveIndex(index),
})}
- />
+ >
+ {selectedItemLabel}
+
);
})}
className.substring(0, className.indexOf(' '));
diff --git a/site/docs/components/component_overview.mdx b/site/docs/components/component_overview.mdx
index 46ca3e3be4..2c297b6ee5 100644
--- a/site/docs/components/component_overview.mdx
+++ b/site/docs/components/component_overview.mdx
@@ -67,6 +67,7 @@ Dropdown | Stable | [](/storybook/core/?path=/story/components-radio-button--default) | [](/storybook/react/?path=/story/components-radiobutton--default)
[Select](/components/dropdown) | Stable | | [](/storybook/react/?path=/story/components-dropdowns-select--default)
[Status label](/components/status-label) | Stable | [](/storybook/core/?path=/story/components-status-label--default) | [](/storybook/react/?path=/story/components-status-label)
+[Tag](/components/tag) | Pre-release | [](/storybook/core/?path=/story/components-tag--default) | [](/storybook/react/?path=/story/components-tag--default)
[Text input](/components/text-field) | Stable | [](/storybook/core/?path=/story/components-textinput--default) | [](/storybook/react/?path=/story/components-textinput--default)
[Text area](/components/text-field#text-area) | Stable | [](/storybook/core/?path=/story/components-text-input--default) | [](/storybook/react/?path=/story/components-textarea--default)
[Tooltip](/components/tooltip) | Pre-release | | [](/storybook/react/?path=/story/components-tooltip--default)
diff --git a/site/docs/components/tag.mdx b/site/docs/components/tag.mdx
new file mode 100644
index 0000000000..2a677f0ac5
--- /dev/null
+++ b/site/docs/components/tag.mdx
@@ -0,0 +1,160 @@
+---
+name: Tag
+menu: Components
+route: /components/tag
+---
+
+import { Playground } from "docz";
+import { Tag, StatusLabel } from "hds-react";
+
+import LargeParagraph from "../../src/components/LargeParagraph";
+import Link from "../../src/components/Link";
+
+# Tag
+
+New
+Pre-release
+Accessible
+
+
+ Tags are used to show attributes of an object or element such as categories. HDS also uses Tags to present filters selected for searches.
+
+
+## Principles
+
+- **Tags are meant for presenting object attributes and filters.** If you are presenting status information, use [Status label component](/components/status-label) instead.
+- Keep labels short and concise. Use 1-2 words at maximum and do not use labels expanding to two rows.
+- Do not use icons inside Tag labels.
+- Tags are often related to some other element on the page (e.g. table row or search field as filters). Aim to keep tags and their related elements close to each other so the user can easily interpret the relation.
+- Unlike status labels, **tags can be configured to be clickable and deletable**. You can use this feature to create removable filters/selections or links to category filtered pages.
+
+## Accessibility
+
+- For interactable Tags you must set a descriptive `aria-label` for assistive technologies so the user understands what happens if the Tag is clicked. For example `aria-label="Move to category: "`.
+- **It is advisable to use colour combinations provided by the implementation.** These combinations are ensured to comply with WCAG AA requirements. When customising colours, refer to [colour guidelines](/design-tokens/colour "Colour") to ensure accessibility.
+- If you are customising tag colours, make sure they are easily distinguishable from [HDS UI Colours](/design-tokens/colour#ui-colours). These colours are reserved to present UI state and status information in applications using HDS.
+- Remember that colour should never be the only way of conveying information. Make sure the meaning of the status label is clearly described by the label text. Refer to WCAG 2.1 Use of Color guideline for more information.
+
+### Which role attribute should be used with Tags?
+- HDS Tags can be clickable. In this case, it needs either a `role=“link”` or `role=“button”` as an attribute. The role value should be decided as follows:
+ - If the user’s focus is moved to another location or another page is opened, the role should be `link`. Example: The user clicks a Tag labeled as "News". The tag takes the user to a new page which lists all items tagged as "News".
+ - If, however, the tag will result in the page’s content being dynamically changed (i.e. Tag triggers an action), use `role=“button”`. Example: Clicking the tag will cause a search below to be filtered.
+
+## Usage and variations
+
+### Basic tags
+
+By default, Tags are non-interactable elements. They only include a label and do not have any specific styling.
+
+
+News
+Announcements
+
+
+##### Core:
+```html
+
+ News
+
+
+
+ Announcements
+
+```
+
+##### React:
+```tsx
+News
+Announcements
+```
+
+### Clickable tags
+
+Tags can be configured to be interactable by giving them an `onClick` function prop. This way Tags can act as links or actions. Since these Tags are fully interactable they can be also focused and receive default HDS focus indicator styling.
+
+Remember to add descriptive `aria-label` to clearly indicate the link target or action to assistive technologies.
+
+
+ {}} aria-label="Move to category: News">News
+ {}} aria-label="Move to category: Announcements" style={{ marginLeft: 'var(--spacing-s)' }}>Announcements
+
+
+##### Core:
+```html
+
+ News
+
+
+
+ Announcements
+
+```
+
+##### React:
+```tsx
+ {}}
+ aria-label="Move to category: News"
+>News
+
+ {}}
+ aria-label="Move to category: Announcements"
+>Announcements
+```
+
+### Deletable tags
+
+Tags can be configured to be deletable by giving them an `onDelete` function prop. This enables a delete icon inside the Tag. Deleting can be useful in situations where Tags are used as filters (e.g. for search).
+
+Remember to add descriptive `aria-label` to the delete button to clearly indicate what the user is deleting when triggering the action.
+
+
+ {}} deleteButtonAriaLabel="Delete filter: News">News
+ {}} deleteButtonAriaLabel="Delete filter: Announcements" style={{ marginLeft: 'var(--spacing-s)' }}>Announcements
+
+
+##### Core:
+```html
+