> For the complete documentation index, see [llms.txt](https://docs.flowty.io/developer-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flowty.io/developer-docs/nft-metadata-standard/traits.md).

# Traits

What data exists on this NFT?

Traits are a very important metadata view because they tell Flowty how to enable filtering. The Traits view itself is a wrapper around an array of traits. Each trait contains:

1. The *name* of the trait (example: "Eyes")&#x20;
2. The *value* of the trait (example: "Happy")
   * Values can be anything, but complex values are currently unsupported
   * If you want a trait to be grouped properly, limit them to primitive values such as "String", "Int", or "Bool"
   * If more than 10 values exist in the collection, a search bar will show up instead
3. The *rarity* of the trait (Optional)
   * If you specify rarity, setting its description to one of the following will color-code the trait:
     * Common
     * Uncommon
     * Default (the value if left blank)
     * Epic
     * Rare
     * Legendary

<figure><img src="https://1110140566-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYhIgoCq3USH1in8LHiq2%2Fuploads%2FSZt6108ieXiuaKAVXORK%2FTraits.png?alt=media&amp;token=3c9c6354-f9d6-41be-bbcd-56ad379c1964" alt=""><figcaption><p>Sample trait name and value (<a href="https://github.com/Flowtyio/avataaars">Avataaars</a>) </p></figcaption></figure>

{% tabs %}
{% tab title="Sample" %}

```
pub resource NFT: NonFungibleToken.INFT, MetadataViews.Resolver {
    // ...

    pub fun resolveView(_ view: Type): AnyStruct? {
        switch view {
            // ...
            case Type<MetadataViews.Traits>():
                // dict must be a subset of `{String: AnyStruct}`, Avataaars uses `{String: String}`
                let traitsView = MetadataViews.dictToTraits(dict: self.renderer.flattened, excludedNames: [])
                return traitsView

        }
        return nil
    }

    // ...
}
```

{% endtab %}

{% tab title="Definition" %}

```
/// View to represent a single field of metadata on an NFT.
/// This is used to get traits of individual key/value pairs along with some
/// contextualized data about the trait
///
pub struct Trait {
    // The name of the trait. Like Background, Eyes, Hair, etc.
    pub let name: String

    // The underlying value of the trait, the rest of the fields of a trait provide context to the value.
    pub let value: AnyStruct

    // displayType is used to show some context about what this name and value represent
    // for instance, you could set value to a unix timestamp, and specify displayType as "Date" to tell
    // platforms to consume this trait as a date and not a number
    pub let displayType: String?

    // Rarity can also be used directly on an attribute.
    //
    // This is optional because not all attributes need to contribute to the NFT's rarity.
    pub let rarity: Rarity?

    // truncated
}

/// Wrapper view to return all the traits on an NFT.
/// This is used to return traits as individual key/value pairs along with
/// some contextualized data about each trait.
pub struct Traits {
    pub let traits: [Trait]
}
```

{% endtab %}
{% endtabs %}
