Repository navigation
TagWrapper
TagWrapper wraps any child element with any tag element, positioning the tag either to the left or right of the content. The tag can be toggled on or off without unmounting the child.
Use TagWrapper when a component needs to annotate a heading, label, or UI element with a status tag while keeping the layout logic in one place. Because the tag prop accepts any ReactElement, TagWrapper works with any tag type — LegacyDataTag, UnderConstructionTag, or any future tag component — without needing dedicated wrapper variants per tag type.
- Source:
frontend/src/components/core/Tags/TagWrapper/index.tsx - Tests:
frontend/src/components/core/Tags/TagWrapper/index.unit.test.tsx
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
children |
ReactElement |
Yes | — | The primary content to display. |
tag |
ReactElement |
Yes | — | The tag element to display alongside the children. |
position |
'left' | 'right' |
No | 'right' |
Position of the tag relative to the children. |
enabled |
boolean |
No | true |
When false, the tag is hidden entirely. Children are always rendered. |
- Renders a
div.tag-wrapperthat contains the children and optionally the tag. - When
position="right"(default): renders{children} {tag}. - When
position="left": renders{tag} {children}. - When
enabled=false: thetagelement is not rendered;childrenis always rendered regardless ofenabled.
import TagWrapper from '@/components/core/Tags/TagWrapper';
import LegacyDataTag from '@/components/core/Tags/LegacyDataTag';
<TagWrapper tag={<LegacyDataTag url="/record/1" />}>
<PageTitle title="Reporting Unit no.: 1234" />
</TagWrapper><TagWrapper
position="right"
enabled={!data.grade?.code}
tag={<LegacyDataTag url={`/legacy?id=${data.id}`} />}
>
<h1>{data.name}</h1>
</TagWrapper>When data.grade.code is truthy, enabled evaluates to false and the tag is suppressed.
-
childrenmust be a singleReactElement. Wrapping multiple elements requires a fragment or container. - The
tag-wrapperCSS class must be present in the compiled stylesheet (index.scss). Visual layout depends on the accompanying styles. -
enabledhides the tag element only; thechildrenprop renders unconditionally.
-
codes/frontend/Components.md— catalog entry for core tags section. -
codes/frontend/core/Tags/LegacyDataTag.md— primary tag used withTagWrapperin the RU details page. -
pages/ReportingUnitDetails— nests twoTagWrapperinstances to annotate the page title with bothLegacyDataTagandUnderConstructionTag.
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository