Skip to main content
2.0.61
Light Dark System
Compact Comfortable

Defined Label

<zn-defined-label> ZnDefinedLabel
Since 1.0 experimental

This component provides a labeled input with support for predefined and custom labels, allowing users to select or enter label-value pairs within a dropdown interface.


<zn-defined-label
  allow-custom
  predefined-labels="[{&quot;name&quot;:&quot;asc2&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;one&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;outbound&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;two&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;another&quot;,&quot;options&quot;:[&quot;one&quot;,&quot;two&quot;,&quot;three&quot;]},{&quot;name&quot;:&quot;awesome&quot;,&quot;options&quot;:[&quot;one&quot;,&quot;two&quot;,&quot;three&quot;,&quot;four&quot;]}]">
</zn-defined-label>

Examples

Basic Usage with Text Input

Create labels with free-form text values by defining labels without options.

<zn-defined-label
  predefined-labels="[{&quot;name&quot;:&quot;priority&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;status&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;category&quot;,&quot;options&quot;:[]}]">
</zn-defined-label>

Labels with Dropdown Options

Define labels with predefined value options for structured data entry.

<zn-defined-label
  predefined-labels="[{&quot;name&quot;:&quot;priority&quot;,&quot;options&quot;:[&quot;low&quot;,&quot;medium&quot;,&quot;high&quot;,&quot;critical&quot;]},{&quot;name&quot;:&quot;status&quot;,&quot;options&quot;:[&quot;open&quot;,&quot;in progress&quot;,&quot;closed&quot;]},{&quot;name&quot;:&quot;type&quot;,&quot;options&quot;:[&quot;bug&quot;,&quot;feature&quot;,&quot;improvement&quot;]}]">
</zn-defined-label>

Allow Custom Labels

Enable users to create their own labels using the allow-custom attribute.

<zn-defined-label
  allow-custom
  predefined-labels="[{&quot;name&quot;:&quot;priority&quot;,&quot;options&quot;:[&quot;low&quot;,&quot;medium&quot;,&quot;high&quot;]},{&quot;name&quot;:&quot;status&quot;,&quot;options&quot;:[&quot;open&quot;,&quot;closed&quot;]}]">
</zn-defined-label>

Mixed Input Types

Combine labels with dropdown options and free-text values.

<zn-defined-label
  allow-custom
  predefined-labels="[{&quot;name&quot;:&quot;department&quot;,&quot;options&quot;:[&quot;engineering&quot;,&quot;sales&quot;,&quot;marketing&quot;,&quot;support&quot;]},{&quot;name&quot;:&quot;project&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;version&quot;,&quot;options&quot;:[&quot;1.0&quot;,&quot;2.0&quot;,&quot;3.0&quot;]},{&quot;name&quot;:&quot;assignee&quot;,&quot;options&quot;:[]}]">
</zn-defined-label>

Different Input Sizes

Control the input size using the input-size attribute.

<div class="form-spacing">
  <zn-defined-label
    input-size="small"
    predefined-labels="[{&quot;name&quot;:&quot;tag&quot;,&quot;options&quot;:[]}]">
  </zn-defined-label>

  <zn-defined-label
    input-size="medium"
    predefined-labels="[{&quot;name&quot;:&quot;tag&quot;,&quot;options&quot;:[]}]">
  </zn-defined-label>

  <zn-defined-label
    input-size="large"
    predefined-labels="[{&quot;name&quot;:&quot;tag&quot;,&quot;options&quot;:[]}]">
  </zn-defined-label>
</div>

Disabled State

Disable the input using the disabled attribute.

<zn-defined-label
  disabled
  predefined-labels="[{&quot;name&quot;:&quot;priority&quot;,&quot;options&quot;:[&quot;low&quot;,&quot;medium&quot;,&quot;high&quot;]}]">
</zn-defined-label>

Custom Name Attribute

Specify a custom form field name using the name attribute.

<form>
  <zn-defined-label
    name="custom-label"
    allow-custom
    predefined-labels="[{&quot;name&quot;:&quot;tag&quot;,&quot;options&quot;:[]}]">
  </zn-defined-label>
</form>

Issue Tracking Labels

A practical example for issue tracking systems.

<zn-defined-label
  allow-custom
  predefined-labels="[{&quot;name&quot;:&quot;priority&quot;,&quot;options&quot;:[&quot;p0&quot;,&quot;p1&quot;,&quot;p2&quot;,&quot;p3&quot;]},{&quot;name&quot;:&quot;type&quot;,&quot;options&quot;:[&quot;bug&quot;,&quot;feature&quot;,&quot;task&quot;,&quot;epic&quot;]},{&quot;name&quot;:&quot;component&quot;,&quot;options&quot;:[&quot;frontend&quot;,&quot;backend&quot;,&quot;api&quot;,&quot;database&quot;]},{&quot;name&quot;:&quot;environment&quot;,&quot;options&quot;:[&quot;dev&quot;,&quot;staging&quot;,&quot;production&quot;]},{&quot;name&quot;:&quot;assignee&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;sprint&quot;,&quot;options&quot;:[]}]">
</zn-defined-label>

Content Tagging

Use for tagging content with categories and metadata.

<zn-defined-label
  allow-custom
  predefined-labels="[{&quot;name&quot;:&quot;category&quot;,&quot;options&quot;:[&quot;article&quot;,&quot;tutorial&quot;,&quot;guide&quot;,&quot;reference&quot;]},{&quot;name&quot;:&quot;difficulty&quot;,&quot;options&quot;:[&quot;beginner&quot;,&quot;intermediate&quot;,&quot;advanced&quot;]},{&quot;name&quot;:&quot;language&quot;,&quot;options&quot;:[&quot;javascript&quot;,&quot;python&quot;,&quot;java&quot;,&quot;go&quot;]},{&quot;name&quot;:&quot;topic&quot;,&quot;options&quot;:[]},{&quot;name&quot;:&quot;author&quot;,&quot;options&quot;:[]}]">
</zn-defined-label>

E-commerce Product Labels

Label products with attributes and characteristics.

<zn-defined-label
  allow-custom
  predefined-labels="[{&quot;name&quot;:&quot;size&quot;,&quot;options&quot;:[&quot;xs&quot;,&quot;s&quot;,&quot;m&quot;,&quot;l&quot;,&quot;xl&quot;,&quot;xxl&quot;]},{&quot;name&quot;:&quot;color&quot;,&quot;options&quot;:[&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;,&quot;black&quot;,&quot;white&quot;]},{&quot;name&quot;:&quot;material&quot;,&quot;options&quot;:[&quot;cotton&quot;,&quot;polyester&quot;,&quot;wool&quot;,&quot;silk&quot;]},{&quot;name&quot;:&quot;season&quot;,&quot;options&quot;:[&quot;spring&quot;,&quot;summer&quot;,&quot;fall&quot;,&quot;winter&quot;]},{&quot;name&quot;:&quot;brand&quot;,&quot;options&quot;:[]}]">
</zn-defined-label>

Properties

Name Description Reflects Type Default
value The selected label key. Also acts as the filter while typing. string ''
inputValue The value entered for the selected label. Submitted as label:value when present. string ''
inputSize
input-size
The size of the main input. 'x-small' | 'small' | 'medium' | 'large' 'medium'
name The name of the control. Used for form submission. string 'label'
title The title of the main input. string -
disabled Disables the control. boolean false
allowCustom
allow-custom
Allows labels that aren’t in the predefined list. boolean false
predefinedLabels
predefined-labels
The predefined labels. Entries are either a string or {name, options}. (PredefinedLabel | string)[] []
updateComplete A read-only promise that resolves when the component has finished updating.

Parts

Name Description
input The component’s main input.
input-value The label’s value inputs.

Dependencies

This component automatically imports the following dependencies.

  • <zn-button>
  • <zn-color-picker>
  • <zn-dropdown>
  • <zn-icon>
  • <zn-input>
  • <zn-opt-group>
  • <zn-option>
  • <zn-popup>
  • <zn-select>
  • <zn-slash-item>
  • <zn-slash-menu>
  • <zn-tag>
  • <zn-tooltip>