Example:

Block:  Hitesh\Vaghasiya\Block\Widget\Link
Template file: module\widget\link_block.phtml
Other Arguments:
 1. Title
 2. Option1
 3. Option2 *
 *Requied Argument must add when called the widget in .phtml or layout XML

Magento 2 : How to call widget in .phtml

<?php echo $this->getLayout()->createBlock("Hitesh\Vaghasiya\Block\Widget\Link")->setTitle("WidgetTitle")->setOption1("Data1")->setOption2("Data2")->setTemplate("module\widget\link_block.phtml")->toHtml(); ?>

Magento 2 : How to call widget in layout XML

<block class="Hitesh\Vaghasiya\Block\Widget\Link" name="demoBlock" template="module\widget\link_block.phtml">
    <action method="setData">
        <argument name="title" xsi:type="string">WidgetTitle</argument>
        <argument name="option1" xsi:type="string">Data1</argument>
        <argument name="option2" xsi:type="string">Data2</argument>
    </action>
</block>

Magento 2 : How to call widget in CMS

{{widget type="Hitesh\Vaghasiya\Block\Widget\Link" title="WidgetTitle" option1="Data1" option2="Data2" template="module\widget\link_block.phtml"}}
Hitesh Vaghasiya

Hitesh Vaghasiya

Full stack Magento developer