Add css to theme function I'm declaring, on my module, a custom theme function:

&lt;?php 
function monitor_chart_theme() {
  return array(
    'chart_monitor' =&gt; array(
      'template' =&gt; 'monitor_chart',
      'variables' =&gt; array(
        'container' =&gt; null,
        'theme' =&gt; null,
        'classes' =&gt; null,
        'chart' =&gt; null,
      ),
    ),
  );
}
?&gt;


On my tpl I would like to add additional classes that I want to pass when I call the function.
Now I've declared a preprocess functions like this: 

&lt;?php    
function monitor_chart_preprocess_chart_monitor(&amp;$vars) {
  if ($vars['classes']) {
    foreach ($vars['classes'] as $class) {
      $vars['classes_array'][] = $class;
    }
  }
}
?&gt;


My tpl is this:

&lt;div id="&lt;?php print $container; ?&gt;" class="&lt;?php print $classes; ?&gt;"&gt;&lt;/div&gt;


If I don't use the preprocess function, "class" attribute of the div has value "chart-monitor", the name of the theme function.

Is there a more elegant way to pass extra variables to my tpl?

Thanks a lot.
Yes, arguments can be passed when calling the theme function:

$tpl_data = array(
    'data1' =&gt; $data1,
    'data2' =&gt; $data2,
);

return theme('my_theme', $tpl_data);


Then in the template $data1 and $data2 will be available.

To add a variable passed here to the default drupal class variable in the template we could add the line:

$class .= " $data1";


before the $class variable is printed. 

However I think it's questionable  whether or not this method is preferable to your original.