diff --git a/packages/dnb-design-system-portal/src/pages/uilib/components/form-label/form-label-properties.md b/packages/dnb-design-system-portal/src/pages/uilib/components/form-label/form-label-properties.md index 67dac9b6e35..9e50d47c91a 100644 --- a/packages/dnb-design-system-portal/src/pages/uilib/components/form-label/form-label-properties.md +++ b/packages/dnb-design-system-portal/src/pages/uilib/components/form-label/form-label-properties.md @@ -9,3 +9,4 @@ draft: true | `vertical` | _(optional)_ is a short hand to define a `vertical` direction if set to `true`. | | `title` | _(optional)_ the `title` attribute of the label. | | `text` | _(optional)_ the `text` of the label. | +| `element` | _(optional)_ defines the HTML element used. Defaults to `label`. | diff --git a/packages/dnb-ui-lib/src/components/checkbox/__tests__/__snapshots__/Checkbox.test.js.snap b/packages/dnb-ui-lib/src/components/checkbox/__tests__/__snapshots__/Checkbox.test.js.snap index c436492313b..1cc1a51314e 100644 --- a/packages/dnb-ui-lib/src/components/checkbox/__tests__/__snapshots__/Checkbox.test.js.snap +++ b/packages/dnb-ui-lib/src/components/checkbox/__tests__/__snapshots__/Checkbox.test.js.snap @@ -30,6 +30,7 @@ exports[`Checkbox component have to match snapshot 1`] = ` className={null} direction={null} disabled="disabled" + element="label" for_id="id" id="id-label" render_content={null} @@ -37,13 +38,20 @@ exports[`Checkbox component have to match snapshot 1`] = ` title={null} vertical={null} > - + + - + + {content} + return ( + + {content} + + ) } } + +const Element = ({ is: Element, children, ...rest }) => ( + {children} +) +Element.propTypes = { + is: PropTypes.string.isRequired, + children: PropTypes.node.isRequired +} diff --git a/packages/dnb-ui-lib/src/components/form-label/__tests__/FormLabel.test.js b/packages/dnb-ui-lib/src/components/form-label/__tests__/FormLabel.test.js index 33f1b2ca82a..67238bfa2a6 100644 --- a/packages/dnb-ui-lib/src/components/form-label/__tests__/FormLabel.test.js +++ b/packages/dnb-ui-lib/src/components/form-label/__tests__/FormLabel.test.js @@ -22,6 +22,7 @@ import dnb_form_label_theme_ui from '../style/themes/dnb-form-label-theme-ui.scs const props = fakeProps(require.resolve('../FormLabel'), { optional: true }) +props.element = 'label' props.direction = 'horizontal' describe('FormLabel component', () => { diff --git a/packages/dnb-ui-lib/src/components/form-label/__tests__/__snapshots__/FormLabel.test.js.snap b/packages/dnb-ui-lib/src/components/form-label/__tests__/__snapshots__/FormLabel.test.js.snap index 2bd370075bc..9c316a3e89a 100644 --- a/packages/dnb-ui-lib/src/components/form-label/__tests__/__snapshots__/FormLabel.test.js.snap +++ b/packages/dnb-ui-lib/src/components/form-label/__tests__/__snapshots__/FormLabel.test.js.snap @@ -6,6 +6,7 @@ exports[`FormLabel component have to match snapshot 1`] = ` className="className" direction="horizontal" disabled="disabled" + element="label" for_id="for_id" id="id" render_content={[Function]} @@ -13,14 +14,22 @@ exports[`FormLabel component have to match snapshot 1`] = ` title="title" vertical="vertical" > - + + `; diff --git a/packages/dnb-ui-lib/src/components/form-row/__tests__/__snapshots__/FormRow.test.js.snap b/packages/dnb-ui-lib/src/components/form-row/__tests__/__snapshots__/FormRow.test.js.snap index 4ab191d5275..6816a9bb447 100644 --- a/packages/dnb-ui-lib/src/components/form-row/__tests__/__snapshots__/FormRow.test.js.snap +++ b/packages/dnb-ui-lib/src/components/form-row/__tests__/__snapshots__/FormRow.test.js.snap @@ -24,6 +24,7 @@ exports[`FormRow component have to match snapshot 1`] = ` className="dnb-form-row__label" direction={null} disabled={false} + element="label" for_id="form-row" id="label_id-label" render_content={null} @@ -31,13 +32,20 @@ exports[`FormRow component have to match snapshot 1`] = ` title={null} vertical={null} > - + +
- + + - + +
- + + - + + - + + - + + - + + - + +