# Tag — SvelteKit UI

Package: sveltekit-ui 1.1.94

Page: https://www.sveltekit-ui.com/components/tag

Category: Data & content

Displays a styled tag record or selects the first tag whose predicates match a dynamic value.

Public component import: `Tag`

Public manager import: `create_tag_manager`

## Component notes

- data_shapes:
  - predicate: { type: 'predicate', predicate: 'equal_to' | 'not_equal_to' | 'less_than' | 'less_than_or_equal' | 'greater_than' | 'greater_than_or_equal' | 'contains' | 'does_not_contain' | 'starts_with' | 'ends_with', value: expected_value }. Equality is strict; string/array predicates require the corresponding actual-value method.
  - operator: { type: 'operator', operator: 'any_of' | 'all_of', conditions: (predicate | nested operator)[] }. any_of uses OR; other operator values use AND. Nested operator conditions are supported.
- notes:
  - The tag text/background use color.c and color.h token indexes. The optional icon manager currently receives the complete color value; omit icon when supplying the { c, h } tag color object.

## Usage

```svelte
<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { Tag, create_tag_manager } from "sveltekit-ui"

  const manager = create_tag_manager({
    val: { display_text: "Published", color: { c: 12, h: 10 } },
  })
</script>

<Tag {manager} />
```

## Configuration

### `val`

- type: any
- description: In static mode a tag record { display_text?: string, color?: { c: number, h: number }, icon?: icon_id }. In dynamic mode the raw value matched against tag_options. Color c/h select numbered theme tokens.

### `is_dynamic`

- type: boolean
- default: false
- description: Use tag_options predicates to derive the displayed record instead of rendering val directly.

### `tag_options`

- type: array
- default:
- description: Ordered tag records with an additional match_for expression. First matching record wins; no match renders no tag.

### `data_type`

- type: any
- description: Optional metadata returned by the manager; it does not validate or coerce val.

## Methods

### `set_val()`

- parameters:
  - input: any
- returns: void
- description: Replace the raw value or static tag record.

### `set_tag_options()`

- parameters:
  - input: array
- returns: void
- description: Replace available tag records; non-array input becomes an empty list.

### `init()`

- parameters:
  - config: tag configuration
- returns: void
- description: Set value, mode, metadata, tag options, and the icon manager.

## Returned state

### `val`

- type: any
- description: Current raw value or static tag record.

### `tag_val`

- type: object | null
- description: Displayed tag record; first matching tag in dynamic mode or val in static mode.

### `tag_options`

- type: array
- description: Configured matching tag records.

### `data_type`

- type: any
- description: Configured metadata.

### `icon_manager`

- type: object
- description: Optional tag icon's manager.
