0.42.2 • Published 25 days ago

@spectrum-web-components/field-label v0.42.2

Weekly downloads
350
License
Apache-2.0
Repository
github
Last release
25 days ago

Description

An <sp-field-label> provides accessible labelling for form elements. Use the for attribute to outline the id of an element in the same DOM tree to which it should associate itself.

Usage

See it on NPM! How big is this package in your project? Try it on webcomponents.dev

yarn add @spectrum-web-components/field-label

Import the side effectful registration of <sp-field-label> via:

import '@spectrum-web-components/field-label/sp-field-label.js';

When looking to leverage the FieldLabel base class as a type and/or for extension purposes, do so via:

import { FieldLabel } from '@spectrum-web-components/field-label';

Sizes

<sp-field-label for="lifestory-0" size="s">Life Story</sp-field-label>
<sp-textfield
    placeholder="Enter your life story"
    id="lifestory-0"
></sp-textfield>
<sp-field-label for="lifestory-1" size="m">Life Story</sp-field-label>
<sp-textfield
    placeholder="Enter your life story"
    id="lifestory-1"
></sp-textfield>
<sp-field-label for="lifestory-2" size="l">Life Story</sp-field-label>
<sp-textfield
    placeholder="Enter your life story"
    id="lifestory-2"
></sp-textfield>
<sp-field-label for="lifestory-3" size="xl">Life Story</sp-field-label>
<sp-textfield
    placeholder="Enter your life story"
    id="lifestory-3"
></sp-textfield>

Examples

<sp-field-label for="lifestory">Life Story</sp-field-label>
<sp-textfield placeholder="Enter your life story" id="lifestory"></sp-textfield>
<sp-field-label for="birth-place">Birthplace</sp-field-label>
<sp-picker id="birth-place">
    <span slot="label">Choose a location:</span>
    <sp-menu-item>Istanbul</sp-menu-item>
    <sp-menu-item>London</sp-menu-item>
    <sp-menu-item>Maputo</sp-menu-item>
    <sp-menu-item>Melbuorne</sp-menu-item>
    <sp-menu-item>New York</sp-menu-item>
    <sp-menu-item>San Fransisco</sp-menu-item>
    <sp-menu-item>Santiago</sp-menu-item>
    <sp-menu-item>Tokyo</sp-menu-item>
</sp-picker>

Side Aligned

Using the side-aligned attribute will display the <sp-field-label> element inline with surrounding elements and the start and end values outline the alignment of the label text in the width specified.

Start

Use side-aligned="start" to display the <sp-field-label> inline and to align the label text to the "start" of the flow of text:

<sp-field-label for="lifestory-1" side-aligned="start" style="width: 120px">
    Life Story
</sp-field-label>
<sp-textfield
    placeholder="Enter your life story"
    id="lifestory-1"
></sp-textfield>
<br />
<br />
<sp-field-label
    for="birth-place-1"
    side-aligned="start"
    required
    style="width: 120px"
>
    Birthplace
</sp-field-label>
<sp-picker id="birth-place-1">
    <span slot="label">Choose a location:</span>
    <sp-menu-item>Istanbul</sp-menu-item>
    <sp-menu-item>London</sp-menu-item>
    <sp-menu-item>Maputo</sp-menu-item>
    <sp-menu-item>Melbuorne</sp-menu-item>
    <sp-menu-item>New York</sp-menu-item>
    <sp-menu-item>San Fransisco</sp-menu-item>
    <sp-menu-item>Santiago</sp-menu-item>
    <sp-menu-item>Tokyo</sp-menu-item>
</sp-picker>

End

Use side-aligned="end" to display the <sp-field-label> inline and to align the label text to the "end" of the flow of text:

<sp-field-label
    for="lifestory-1"
    side-aligned="end"
    required
    style="width: 120px"
>
    Life Story
</sp-field-label>
<sp-textfield
    placeholder="Enter your life story"
    id="lifestory-1"
></sp-textfield>
<br />
<br />
<sp-field-label for="birth-place-1" side-aligned="end" style="width: 120px">
    Birthplace
</sp-field-label>
<sp-picker id="birth-place-1">
    <span slot="label">Choose a location:</span>
    <sp-menu-item>Istanbul</sp-menu-item>
    <sp-menu-item>London</sp-menu-item>
    <sp-menu-item>Maputo</sp-menu-item>
    <sp-menu-item>Melbuorne</sp-menu-item>
    <sp-menu-item>New York</sp-menu-item>
    <sp-menu-item>San Fransisco</sp-menu-item>
    <sp-menu-item>Santiago</sp-menu-item>
    <sp-menu-item>Tokyo</sp-menu-item>
</sp-picker>
0.42.2

25 days ago

0.42.1

25 days ago

0.42.0

1 month ago

0.41.2

2 months ago

0.41.1

2 months ago

0.41.0

2 months ago

0.40.5

3 months ago

0.40.4

3 months ago

0.40.3

4 months ago

0.40.2

4 months ago

0.40.1

5 months ago

0.36.0

8 months ago

0.40.0

5 months ago

0.35.1-rc.15

9 months ago

0.37.0

8 months ago

0.34.1-rc.0

10 months ago

0.35.1-rc.25

9 months ago

0.35.1-rc.26

9 months ago

0.35.1-rc.24

9 months ago

0.38.0

8 months ago

0.35.1-rc.34

9 months ago

0.34.0

10 months ago

0.35.1-rc.43

9 months ago

0.35.1-rc.41

9 months ago

0.39.1

7 months ago

0.39.0

7 months ago

0.35.0

9 months ago

0.39.4

6 months ago

0.39.3

6 months ago

0.39.2

7 months ago

0.33.3-overlay.66

10 months ago

0.33.3-overlay.65

10 months ago

0.33.3-overlay.61

10 months ago

0.31.1-react.21

11 months ago

0.32.0

11 months ago

0.31.1-react.3

12 months ago

0.31.1-react.2

12 months ago

0.30.1-overlay.30

12 months ago

0.33.1-overlay.39

11 months ago

0.30.1-overlay.31

12 months ago

0.33.2

11 months ago

0.33.0

11 months ago

0.30.1-overlay.38

12 months ago

0.30.1-overlay.37

12 months ago

0.30.1-overlay.41

12 months ago

0.30.1-overlay.42

12 months ago

0.30.1-overlay.40

12 months ago

0.30.0

12 months ago

0.33.1-overlay.41

11 months ago

0.32.1-overlay.33

11 months ago

0.32.1-overlay.41

11 months ago

0.31.0

12 months ago

0.31.1-overlay.29

12 months ago

0.10.9

1 year ago

0.10.7

1 year ago

0.10.8

1 year ago

0.10.10

1 year ago

0.10.6-react.75

1 year ago

0.10.6-react.49

1 year ago

0.10.6-react.48

1 year ago

0.10.6

1 year ago

0.10.6-react.50

1 year ago

0.10.3-react.54

1 year ago

0.10.3

1 year ago

0.10.4

1 year ago

0.10.5

1 year ago

0.10.6-react.32

1 year ago

0.9.0

2 years ago

0.9.1

2 years ago

0.10.1

1 year ago

0.10.2

1 year ago

0.10.0

2 years ago

0.7.14-devmode.7

2 years ago

0.7.14-devmode.0

2 years ago

0.8.0-devmode.0

2 years ago

0.7.15-devmode.0

2 years ago

0.7.13

2 years ago

0.7.12

2 years ago

0.7.14

2 years ago

0.8.0

2 years ago

0.7.11

2 years ago

0.7.10

2 years ago

0.7.9

2 years ago

0.7.8

2 years ago

0.7.7

2 years ago

0.7.6

2 years ago

0.7.5

2 years ago

0.7.4-express.12

2 years ago

0.7.5-express.9

2 years ago

0.7.2

2 years ago

0.7.4

2 years ago

0.7.3

2 years ago

0.7.3-express.0

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.6.1-lit-next.0

2 years ago

0.6.0

2 years ago

0.5.9

3 years ago

0.5.8

3 years ago

0.5.9-lit-next.0

3 years ago

0.5.8-lit-next.0

3 years ago

0.5.7

3 years ago

0.5.7-lit-next.0

3 years ago

0.5.6

3 years ago

0.5.6-beta.3

3 years ago

0.5.5

3 years ago

0.5.6-alpha.1

3 years ago

0.5.5-alpha.1

3 years ago

0.5.4

3 years ago

0.5.4-alpha.1

3 years ago

0.5.3

3 years ago

0.5.3-alpha.1

3 years ago

0.5.2

3 years ago

0.5.2-alpha.1

3 years ago

0.5.1

3 years ago

0.5.1-alpha.47

3 years ago

0.5.1-alpha.46

3 years ago

0.5.1-alpha.45

3 years ago

0.5.1-alpha.34

3 years ago

0.5.1-alpha.0

3 years ago

0.5.0

3 years ago

0.4.6-alpha.0

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3-alpha.26

3 years ago

0.4.3

3 years ago

0.4.3-alpha.23

3 years ago

0.4.3-alpha.21

3 years ago

0.4.3-beta.16

3 years ago

0.4.3-beta.15

3 years ago

0.4.3-beta.17

3 years ago

0.4.3-alpha.10

3 years ago

0.4.3-alpha.11

3 years ago

0.4.3-beta.10

3 years ago

0.4.3-alpha.12

3 years ago

0.4.3-beta.12

3 years ago

0.4.3-beta.11

3 years ago

0.4.3-beta.14

3 years ago

0.4.3-beta.13

3 years ago

0.4.3-alpha.17

3 years ago

0.4.3-alpha.9

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.3-alpha.33

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.2-alpha.1403

3 years ago

0.2.0-alpha.1407

3 years ago

0.0.2-alpha.1394

3 years ago