Label

A label is a container for labels, description and tooltip. It has a generic structure and styling for form fields.

Examples

As a basic example, you can use label and description both as string values.



Pure css example: Description content
Tooltip

To set up a tooltip, you can use tooltip and tooltipPlacement. The tooltipPlacement has a default value of bottom

Required

To make the label look required, you can use the required parameter.

Pure css example:
Description content
Optional

Label can have an extra optional label content. By default it is the text "Optional". To change this text, you can use the optionalLabel parameter.

Pure css example:
Description content
Description content
Subtle

You can use the subtle parameter to make the label a bit more subtle.

Pure css example:
Subtle description content
Disabled

To make the label look disabled, you can use the disabled parameter.

Pure css example:
Disabled description content
Size

You can choose different sizes for the label. Default is sm.

Description xs
Disabled sm
Description lg
Importing Per-component import (Recommended)

Import the component by its own subpath. This registers <dap-ds-label> (and the components it renders internally) and lets your bundler include only what you use:

import 'dap-design-system/components/label'

Need a reference to the class (e.g. to register it manually or extend it)? The same subpath default-exports it:

import DapDSLabel from 'dap-design-system/components/label'
Register everything

Register the whole library at once — convenient, but pulls every component into your bundle:

import 'dap-design-system'
Importing React
import { DapDSLabelReact } from 'dap-design-system/react'
Attributes
PropertyTypeDefaultDescription
labelstringThe label text
descriptionstringThe description of the label
tooltipstringThe tooltip text
size'xs', 'sm' , 'lg'The size of the input. Default is sm.
tooltipPlacement'top', 'right' , 'bottom' , 'left'The tooltip placement of the label.
optionalbooleanIf the label is optional. Default value is false.
optionalLabelstringLabel of optional text
requiredLabelstringIndicator of required text (default: '*')
subtlebooleanText weight of label. If true the label is subtle. Default value is false.
disabledbooleanThe disabled state of the label. Default is false.
requiredbooleanThe required state of the label. Default is false.
Slots

No slots available.

Events

No custom events available.

CSS Parts
Part NameDescription
baseThe main label container.
labelTha main label container. dap-ds-form-label element.
label-baseThe label text.
label-requiredThe required indicator of the label.
label-optionalThe optional indicator of the label.
tooltipThe tooltip of the label. dap-ds-tooltip element.
descriptionThe description of the label.
How to Use CSS Parts

You can style CSS parts using the ::part() pseudo-element selector:

/* Target a specific part */
.my-custom-dap-ds-label::part(base) {
  /* Your custom styles */
}

/* Target multiple parts */
.my-custom-dap-ds-label::part(base),
.my-custom-dap-ds-label::part(label) {
  /* Shared styles */
}

Example usage:

<dap-ds-label class="my-custom-dap-ds-label">
  Label
</dap-ds-label>
.my-custom-dap-ds-label::part(base) {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

CSS parts allow you to style internal elements of the component while maintaining encapsulation. Learn more in our styling guide.

CSS Custom Properties
Property NameDescription
--dds-label-backgroundThe background color of the label container. (default: var(--dds-background-neutral-subtle)).
--dds-label-border-colorThe border color of the label container. (default: var(--dds-border-neutral-subtle)).
--dds-label-border-widthThe border width of the label container. (default: var(--dds-border-width-base)).
--dds-label-border-radiusThe border radius of the label container. (default: var(--dds-radius-base)).
--dds-label-paddingThe padding of the label container. (default: var(--dds-spacing-400)).
--dds-label-disabled-backgroundThe background color of the label container when disabled. (default: var(--dds-background-neutral-disabled-inverted)).
--dds-label-checked-border-colorThe border color of the label container when checked. (default: var(--dds-background-brand-base-inverted)).
How to Use CSS Custom Properties

CSS custom properties (CSS variables) can be set directly on the component or in your stylesheet:

Method 1: Inline styles (Quick customization)

<dap-ds-label
  style="--dds-label-background: value; --dds-label-border-color: value;">
  Label
</dap-ds-label>

Method 2: CSS classes (Reusable styles)

.my-custom-dap-ds-label {
  --dds-label-background: value;
  --dds-label-border-color: value;
  --dds-label-border-width: value;
}
<dap-ds-label class="my-custom-dap-ds-label">
  Label
</dap-ds-label>

Method 3: Global theme customization

/* Apply to all instances */
dap-ds-label {
  --dds-label-background: value;
  --dds-label-border-color: value;
}

CSS custom properties inherit through the Shadow DOM, making them perfect for theming. Changes apply immediately without rebuilding.