Label Important warning Deprecated
Labels are used to create text labels for items in an interface. Most commonly used inside other form components. Label is intended for internal use with Duet's form components, avoid using it in application code.
Label must be used only for labelling form elements. Duet's form components have the label attribute for providing the text content for labels - that should be used instead of using Label component in application code. If the need is to label a group of form elements use the Duet Fieldset and its label attribute. If the visual appearance would be the only reason for using Label use Duet Pargraph instead, optionally with attribute weigh="semibold".
Examples #
<duet-label for="identifier">Label text</duet-label> <duet-label size="small" for="identifier">Small label text</duet-label> <duet-label color="gray-darker" weight="normal" for="identifier">Lighter weight and color label text</duet-label> Properties #
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
color | color | Custom color to be used for text, as a design token entered in camelCase or kebab-case. Example: "color-primary". | string | "" |
for | for | ID of the component that the label is labelling. | string | undefined |
margin | margin | Controls the margin of the component. | "auto" | "none" | "small" | "auto" |
size | size | Controls the size of the label. | "medium" | "small" | "medium" |
theme | theme | Theme of the label. | "" | "default" | "turva" | "" |
weight | weight | Controls the weight of the label. | "normal" | "semi-bold" | "semi-bold" |
Usage #
This section includes guidelines for designers and developers about the usage of this component in different contexts.
When to use #
- To represent a caption for an item in a user interface.
- To label button, input, keygen, meter, output, progress, select, or textarea html elements.
When not to use #
- As a heading. Use small size from heading component instead.
- When you need to display interactive elements, such as links. Use paragraph component with link instead.
- To label something else except button, input, keygen, meter, output, progress, select, or textarea html elements.
Accessibility #
This component has been validated to meet the WCAG 2.1 AA accessibility guidelines. You can find additional information regarding accessibility of this component below.
- Label component uses a basic HTML
<label>element behind the scenes and offers similar functionality and API for its users. - Use
forproperty to set the ID of the component that the label is labelling.
Integration
For integration, event and theming guidelines, please see Using Components. This documentation explains how to implement and use Duet’s components across different technologies like Angular, React or Vanilla JavaScript.
Tutorials
Follow these practical tutorials to learn how to build simple page layouts using Duet’s CSS Framework, Web Components and other features:
Building Layouts
TutorialsUsing CLI Tools
TutorialsCreating Custom Patterns
TutorialsServer Side Rendering
TutorialsSharing Prototypes
TutorialsUsage With Markdown
Troubleshooting
If you experience any issues while using a component, please head over to the Support page for more guidelines and help.