Defined Label
<zn-defined-label>
ZnDefinedLabel
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="[{"name":"asc2","options":[]},{"name":"one","options":[]},{"name":"outbound","options":[]},{"name":"two","options":[]},{"name":"another","options":["one","two","three"]},{"name":"awesome","options":["one","two","three","four"]}]"> </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="[{"name":"priority","options":[]},{"name":"status","options":[]},{"name":"category","options":[]}]"> </zn-defined-label>
Labels with Dropdown Options
Define labels with predefined value options for structured data entry.
<zn-defined-label predefined-labels="[{"name":"priority","options":["low","medium","high","critical"]},{"name":"status","options":["open","in progress","closed"]},{"name":"type","options":["bug","feature","improvement"]}]"> </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="[{"name":"priority","options":["low","medium","high"]},{"name":"status","options":["open","closed"]}]"> </zn-defined-label>
Mixed Input Types
Combine labels with dropdown options and free-text values.
<zn-defined-label allow-custom predefined-labels="[{"name":"department","options":["engineering","sales","marketing","support"]},{"name":"project","options":[]},{"name":"version","options":["1.0","2.0","3.0"]},{"name":"assignee","options":[]}]"> </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="[{"name":"tag","options":[]}]"> </zn-defined-label> <zn-defined-label input-size="medium" predefined-labels="[{"name":"tag","options":[]}]"> </zn-defined-label> <zn-defined-label input-size="large" predefined-labels="[{"name":"tag","options":[]}]"> </zn-defined-label> </div>
Disabled State
Disable the input using the disabled attribute.
<zn-defined-label disabled predefined-labels="[{"name":"priority","options":["low","medium","high"]}]"> </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="[{"name":"tag","options":[]}]"> </zn-defined-label> </form>
Issue Tracking Labels
A practical example for issue tracking systems.
<zn-defined-label allow-custom predefined-labels="[{"name":"priority","options":["p0","p1","p2","p3"]},{"name":"type","options":["bug","feature","task","epic"]},{"name":"component","options":["frontend","backend","api","database"]},{"name":"environment","options":["dev","staging","production"]},{"name":"assignee","options":[]},{"name":"sprint","options":[]}]"> </zn-defined-label>
Content Tagging
Use for tagging content with categories and metadata.
<zn-defined-label allow-custom predefined-labels="[{"name":"category","options":["article","tutorial","guide","reference"]},{"name":"difficulty","options":["beginner","intermediate","advanced"]},{"name":"language","options":["javascript","python","java","go"]},{"name":"topic","options":[]},{"name":"author","options":[]}]"> </zn-defined-label>
E-commerce Product Labels
Label products with attributes and characteristics.
<zn-defined-label allow-custom predefined-labels="[{"name":"size","options":["xs","s","m","l","xl","xxl"]},{"name":"color","options":["red","blue","green","black","white"]},{"name":"material","options":["cotton","polyester","wool","silk"]},{"name":"season","options":["spring","summer","fall","winter"]},{"name":"brand","options":[]}]"> </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>