Tags

ADempiereMarch 21, 2023
About 2 min

Used for marking and selection.

Basic Usage

Use the type attribute to define Tag's type. In addition, the color attribute can be used to set the background color of the Tag.

Tag 1Tag 2Tag 3Tag 4Tag 5

Viwer Source

<template>
  <FielTags :value="'Tags 1'" />
  <FielTags :value="'Tags 2'" type="success" />
  <FielTags :value="'Tags 3'" type="info" />
  <FielTags :value="'Tags 4'" type="warning" />
  <FielTags :value="'Tags 5'" type="danger" />
</template>

Sizes

Besides default size, Tag component provides three additional sizes for you to choose among different scenarios.

Use attribute size to set additional sizes with large, default or small.

LargeDefaultSmall

Viwer Source

<template>
  <FielTags :value="'Default'" />
  <FielTags :value="'large'" size="large"/>
  <FielTags :value="'small'" size="small" />
</template>

Theme

Tag provide three different themes: darkใ€light and plain

Using effect to change, default is light

DarkTag 1Tag 2Tag 3Tag 4Tag 5Tag 1Tag 2Tag 3Tag 4Tag 5
LightTag 1Tag 2Tag 3Tag 4Tag 5Tag 1Tag 2Tag 3Tag 4Tag 5
PlainTag 1Tag 2Tag 3Tag 4Tag 5Tag 1Tag 2Tag 3Tag 4Tag 5

Viwer Source

<template>
  <FielTags
    v-for="item in items"
    :key="item.label"
    :type="item.type"
    class="mx-1"
    effect="dark"
    :value="item.label"
  />
  <FielTags
    v-for="item in items"
    :key="item.label"
    :type="item.type"
    class="mx-1"
    effect="light"
    :value="item.label"
  />
  <FielTags
    v-for="item in items"
    :key="item.label"
    :type="item.type"
    class="mx-1"
    effect="plain"
    :value="item.label"
  />
</template>
<script lang="ts" setup>
import { ref } from 'vue'

import type { TagProps } from 'element-plus'

type Item = { type: TagProps['type']; label: string }

const items = ref<Array<Item>>([
  { type: '', label: 'Tag 1' },
  { type: 'success', label: 'Tag 2' },
  { type: 'info', label: 'Tag 3' },
  { type: 'danger', label: 'Tag 4' },
  { type: 'warning', label: 'Tag 5' },
])
</script>

<style>
.el-tag {
  margin: 5px;
}
</style>

Rounded

Tag can also be rounded like button.

Tag 1Tag 2Tag 3Tag 4Tag 5
Tag 1Tag 2Tag 3Tag 4Tag 5
Tag 1Tag 2Tag 3Tag 4Tag 5

Viwer Source

<template>
  <div class="flex flex-wrap gap-2 my-2">
    <el-tag
      v-for="item in items"
      :key="item.label"
      :type="item.type"
      class="mx-1"
      effect="dark"
      round
      :value="item.label"
    />
  </div>
  <div class="flex flex-wrap gap-2">
    <el-tag
      v-for="item in items"
      :key="item.label"
      :type="item.type"
      class="mx-1"
      effect="light"
      round
      :value="item.label"
    />
  </div>
  <div class="flex flex-wrap gap-2 my-2">
    <el-tag
      v-for="item in items"
      :key="item.label"
      :type="item.type"
      class="mx-1"
      effect="plain"
      round
      :value="item.label"
    />
  </div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'

import type { TagProps } from 'element-plus'

type Item = { type: TagProps['type']; label: string }

const items = ref<Array<Item>>([
  { type: '', label: 'Tag 1' },
  { type: 'success', label: 'Tag 2' },
  { type: 'info', label: 'Tag 3' },
  { type: 'danger', label: 'Tag 4' },
  { type: 'warning', label: 'Tag 5' },
])
</script>

Props

NameDescriptionTypeMandatory
valueBinding Value.StringTrue

Attributes

NameDescriptionTypeDefault
typecomponent typeStringโ€”โ€”โ€”โ€”โ€”
effectcomponent theme dark / light / plainStringlight
roundhether Tag is roundedBooleanFalse
sizesize of Switch large / default / smallStringdefault

Example for Developer

Open in StackBlitzopen in new window

Directory

  โ””โ”€ src                                            # Main source code.
      โ””โ”€โ”€ Components                                # Global components
              โ””โ”€โ”€ Atoms                             # Atom components
                  โ””โ”€โ”€ FielTags                      # Field Tags specific components.