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>
Importing
If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.
To import this component from the CDN using a script tag:
<script type="module" src="https://cdn.jsdelivr.net/npm/@kubex/zinc@1.0.86/dist/components/defined-label/defined-label.js"></script>
To import this component from the CDN using a JavaScript import:
import 'https://cdn.jsdelivr.net/npm/@kubex/zinc@1.0.86/dist/components/defined-label/defined-label.js';
To import this component using a bundler:
import '@kubex/zinc/dist/components/defined-label/defined-label.js';
Parts
| Name | Description |
|---|---|
input |
The component’s main input. |
input-value |
The label’s value inputs. |
Learn more about customizing CSS parts.
Dependencies
This component automatically imports the following dependencies.
<zn-button><zn-dropdown><zn-example><zn-icon><zn-input><zn-opt-group><zn-option><zn-panel><zn-popup><zn-select><zn-sp><zn-tag><zn-tooltip>