diff --git a/components/fieldlabel/index.css b/components/fieldlabel/index.css
index 503d3ccc0bd..f2f6cf1baed 100644
--- a/components/fieldlabel/index.css
+++ b/components/fieldlabel/index.css
@@ -91,14 +91,12 @@ governing permissions and limitations under the License.
-webkit-font-smoothing: subpixel-antialiased;
-moz-osx-font-smoothing: auto;
- font-smoothing: subpixel-antialiased;
color: var(--spectrum-fieldlabel-color);
}
/* international lang support */
.spectrum-FieldLabel {
-
&:lang(ja),
&:lang(zh),
&:lang(ko) {
@@ -109,24 +107,18 @@ governing permissions and limitations under the License.
.spectrum-FieldLabel-requiredIcon {
margin-block: 0;
margin-inline: var(--mod-field-label-text-to-asterisk, var(--spectrum-field-label-text-to-asterisk)) 0;
+ vertical-align: var(--mod-field-label-asterisk-vertical-align, baseline);
}
-.spectrum-FieldLabel--left {
+.spectrum-FieldLabel--left,
+.spectrum-FieldLabel--right {
display: inline-block;
padding-block: var(--mod-fieldlabel-side-padding-top, var(--spectrum-fieldlabel-side-padding-top)) 0;
padding-inline: 0 var(--mod-fieldlabel-side-padding-right, var(--spectrum-fieldlabel-side-padding-right));
-
- & .spectrum-FieldLabel-requiredIcon {
- margin-block: var(--mod-field-label-text-to-asterisk, var(--spectrum-field-label-text-to-asterisk)) 0;
- margin-inline: var(--mod-field-label-text-to-asterisk, var(--spectrum-field-label-text-to-asterisk)) 0;
- }
}
.spectrum-FieldLabel--right {
- display: inline-block;
text-align: end;
- padding-block: var(--mod-fieldlabel-side-padding-top, var(--spectrum-fieldlabel-side-padding-top)) 0;
- padding-inline: 0 var(--mod-fieldlabel-side-padding-right, var(--spectrum-fieldlabel-side-padding-right));
}
.spectrum-Form {
@@ -151,7 +143,6 @@ governing permissions and limitations under the License.
}
/* disabled state */
-
.spectrum-FieldLabel,
.spectrum-Form-itemLabel {
&.is-disabled {
@@ -176,7 +167,7 @@ governing permissions and limitations under the License.
display: flex;
flex-direction: column;
- &+.spectrum-Form-item {
+ & + .spectrum-Form-item {
margin-block-start: var(--mod-field-label-top-to-asterisk, var(--spectrum-field-label-top-to-asterisk));
}
}
diff --git a/components/fieldlabel/metadata/fieldlabel.yml b/components/fieldlabel/metadata/fieldlabel.yml
index 73d06982650..34f19798680 100644
--- a/components/fieldlabel/metadata/fieldlabel.yml
+++ b/components/fieldlabel/metadata/fieldlabel.yml
@@ -7,7 +7,7 @@ sections:
- name: Migration Guide
description: |
### T-shirt sizing
- Field Label now supports t-shirt sizing and requires that you specify the size by adding a `.spectrum-FieldLabel--size*` class.
+ Field label now supports t-shirt sizing and requires that you specify the size by adding a `.spectrum-FieldLabel--size*` class.
examples:
- id: fieldlabel-sizing
name: Sizing
@@ -16,7 +16,7 @@ examples:
S
-
Life Story
+
Life story
@@ -24,7 +24,7 @@ examples:
M (default)
-
Life Story
+
Life story
@@ -33,7 +33,7 @@ examples:
L
-
Life Story
+
Life story
@@ -42,7 +42,7 @@ examples:
XL
-
Life Story
+
Life story
@@ -51,39 +51,40 @@ examples:
- id: fieldlabel-standard
name: Standard
markup: |
-
Life Story
+
Life story
-
Life Story
+
Life story
- id: fieldlabel-side-left
name: Left
- description: A left aligned field label.
+ description: A left aligned Field label.
markup: |
-
Life Story
+
Life story
- id: fieldlabel-side-right
name: Right
- description: A right aligned field label.
+ description: A right aligned Field label.
markup: |
-
Life Story
+
Life story
- id: fieldlabel-required
name: Required
- description: Field label for a required field.
+ description: A Field label for a required field can display either the text "(required)", or an asterisk. If using the asterisk icon, do not leave any space between the label text and the start of the `
` element in the markup, so extra space is not added in addition to the inline margin.
markup: |
- Life Story
-
+
+ Life story
@@ -91,7 +92,7 @@ examples:
-
Life Story (Required)
+
Life story (required)
@@ -99,8 +100,9 @@ examples:
-
Life Story
-
+
+ Life story
@@ -108,9 +110,9 @@ examples:
-
-
Life Story
-
+
+ Life story
diff --git a/components/fieldlabel/metadata/mods.md b/components/fieldlabel/metadata/mods.md
index 6abba852184..b38e9c87fe9 100644
--- a/components/fieldlabel/metadata/mods.md
+++ b/components/fieldlabel/metadata/mods.md
@@ -1,15 +1,16 @@
-| Modifiable Custom Properties |
-| ------------------------------------- |
-| `--mod-disabled-content-color` |
-| `--mod-field-label-text-to-asterisk` |
-| `--mod-field-label-top-to-asterisk` |
-| `--mod-fieldlabel-font-size` |
-| `--mod-fieldlabel-font-weight` |
-| `--mod-fieldlabel-line-height` |
-| `--mod-fieldlabel-line-height-cjk` |
-| `--mod-fieldlabel-min-height` |
-| `--mod-fieldlabel-side-padding-right` |
-| `--mod-fieldlabel-side-padding-top` |
-| `--mod-spacing-300` |
-| `--mod-tableform-border-spacing` |
-| `--mod-tableform-margin` |
+| Modifiable Custom Properties |
+| ------------------------------------------- |
+| `--mod-disabled-content-color` |
+| `--mod-field-label-asterisk-vertical-align` |
+| `--mod-field-label-text-to-asterisk` |
+| `--mod-field-label-top-to-asterisk` |
+| `--mod-fieldlabel-font-size` |
+| `--mod-fieldlabel-font-weight` |
+| `--mod-fieldlabel-line-height` |
+| `--mod-fieldlabel-line-height-cjk` |
+| `--mod-fieldlabel-min-height` |
+| `--mod-fieldlabel-side-padding-right` |
+| `--mod-fieldlabel-side-padding-top` |
+| `--mod-spacing-300` |
+| `--mod-tableform-border-spacing` |
+| `--mod-tableform-margin` |
diff --git a/components/fieldlabel/stories/fieldlabel.stories.js b/components/fieldlabel/stories/fieldlabel.stories.js
index 3a82e94fa41..be21243b3e0 100644
--- a/components/fieldlabel/stories/fieldlabel.stories.js
+++ b/components/fieldlabel/stories/fieldlabel.stories.js
@@ -85,3 +85,19 @@ RightAligned.args = {
alignment: "right",
style: { width: "72px" },
};
+
+export const Required = Template.bind({});
+Required.args = {
+ label: "Label example",
+ alignment: "left",
+ isRequired: true,
+ style: { width: "200px" },
+};
+
+export const WrappingAndRequired = Template.bind({});
+WrappingAndRequired.args = {
+ label: "Label example with longer text that will wrap to the next line. And with an asterisk that marks it as required.",
+ alignment: "left",
+ isRequired: true,
+ style: { width: "200px" },
+};
\ No newline at end of file
diff --git a/components/fieldlabel/stories/template.js b/components/fieldlabel/stories/template.js
index 1937abf426d..e53778048d7 100644
--- a/components/fieldlabel/stories/template.js
+++ b/components/fieldlabel/stories/template.js
@@ -63,13 +63,12 @@ export const Template = ({
id=${ifDefined(id)}
for=${ifDefined(forInput)}
>
- ${label}
- ${isRequired
+ ${label}${isRequired
? Icon({
...globals,
size,
iconName,
- customClasses: [`${rootClass}-UIIcon`],
+ customClasses: [`${rootClass}-UIIcon`, `${rootClass}-requiredIcon`],
})
: ""}