Pass values to twig file from #theme options I need to create a select field in a config form and pass values to it along with custom #theme options.
Its easy to pass header &amp; row values. But after selecting a value from select box, I need to load another dropdown, Below is my reference code:
addslider.php
 public function buildForm(array $form, FormStateInterface $form_state) {
 $vid = 'my_categories';
 $terms =\Drupal::entityTypeManager()-&gt;getStorage('taxonomy_term')-&gt;loadTree($vid);

 foreach ($terms as $term) {
   $custom_categories[$term-&gt;tid] = str_repeat('-', $term-&gt;depth) . $term-&gt;name;
 }
  $form['block']['sliders'] = array(
  '#type' =&gt; 'fieldset',
  '#title' =&gt; $this-&gt;t('My Sliders'),
  '#collapsible' =&gt; TRUE,
  '#collapsed' =&gt; TRUE,
  '#theme'  =&gt; 'my_custom_slider_table',
);

foreach ($block['sliders'] as $key =&gt; $slider) {

$form['block']['sliders'][$key]['tid'] = array(
  '#type'          =&gt; 'select',
  '#title'         =&gt; t('Categories'),
  '#options'       =&gt; $custom_categories,
  '#required'      =&gt; TRUE,
  '#default_value' =&gt; !empty($slider['tid']) ? $slider['tid'] : NULL,
);
}

hook_theme() in module file:
function mycustom_theme() {
  return [
    'my_custom_slider_table' =&gt; [
    //'variables' =&gt; [
    //'header' =&gt; $header,
    //'rows' =&gt; $example_rows,
    //'attributes' =&gt; array('id' =&gt; $table_id),
    //],
    'variables' =&gt; [
    'slider ' =&gt; [],
    ],
  ],
];

}

my-custom-slider-table.html.twig file:
&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;{{ 'Taxonomy select' }}&lt;/th&gt;
      &lt;th&gt;{{ 'Reference Node' }}&lt;/th&gt;
      &lt;th&gt;{{ 'Options' }}&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
   &lt;tr&gt; &lt;td&gt;{{ slider }}&lt;/td&gt;&lt;td&gt;Test Sponsors&lt;/td&gt;&lt;td&gt;Edit/Delete&lt;/td&gt;&lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;

I need to get the output of $custom_categories variable in twig file, for the first td in {{ slider }} . Can you please help, new to Drupal8.
You need to add it to your $build render object. Here's a piece of sample code, in this case from a Block plugin with a form on it, similar to yours:
...
in my BlockPlugin
..



public function build() {
    // getConfiguration returns the values from the form I have and save to a config object.
    $source = $this-&gt;getConfiguration()['source'];
    $access_token = $this-&gt;getConfiguration()['access_token'];

    $build = [
      '#theme' =&gt; 'my_fancy_search_widget',
      '#source_data' =&gt; $source,
      '#access_token' =&gt; $access_token,
    ];
    return $build;
  }


...
in my .module file:
...


/**
 * Implements hook_theme().
 */
function my_module_theme($existing, $type, $theme, $path) {
  return [
  'my_fancy_search_widget' =&gt; [
      'template' =&gt; 'main-search',
      'variables' =&gt; [
        'source_data' =&gt; NULL,
        'access_token' =&gt; NULL,
      ],
  ];
}



in my twig template I can print these vars with {{ source_data }} and {{ access_token }}