Give included twig component unique ID When I include specific Twig template component multiple times, how can I give it a unique ID (or class)? 

Components are not inside for loop, so I cannot use loop.index. I also don't wont to pass unique variable myself when I include it. And using random Twig function doesn't ensure that the result is unique. 

Let's also assume that each component doesn't have unique Craft element assigned to it, like entry - in such case, I could just use this entry ID.
You can create a unique ID function in PHP and pass it to Twig

{% set uniqueId = uniqueId() %}


And your PHP part

class Extension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
{
    public $uniqueIds;

    public function getFunctions(): array
    {
        return [
             new Twig_SimpleFunction('uniqueId', [$this, 'getUniqueId'])
        ];
    }

    /**
     * getUniqueId
     *
     * @return string
     */
    public function getUniqueId(): string 
    {
        // generate a random string
        $id = StringHelper::randomString('12');

        // check if it's already set
        while (\in_array($id, $this-&gt;uniqueIds, true)){
            // if so, use another one
            $id = StringHelper::randomString('12');
        }
        // set it as "used"
        $this-&gt;uniqueIds[] = $id;

        return $id;
    }
}