4.7.x form.inc theme_button($element)
5.x form.inc theme_button($element)
6.x form.inc theme_button($element)
7.x form.inc theme_button($variables)

Returns HTML for a button form element.


$variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #attributes, #button_type, #name, #value.

Related topics

1 theme call to theme_button()
theme_submit in includes/form.inc
Returns HTML for a submit button form element.


includes/form.inc, line 3913
Functions for form and batch generation and processing.


function theme_button($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'submit';
  element_set_attributes($element, array(
  $element['#attributes']['class'][] = 'form-' . $element['#button_type'];
  if (!empty($element['#attributes']['disabled'])) {
    $element['#attributes']['class'][] = 'form-button-disabled';
  return '<input' . drupal_attributes($element['#attributes']) . ' />';


Chandan Chaudhary’s picture

I think the element type should be button instead of submit.

I am not sure but for creating a submit button we have '#type = submit'

so the line should be
$element['#attributes']['type'] = 'button';

instead of
$element['#attributes']['type'] = 'submit';

Chandan Chaudhary’s picture

or more specifically it should be

$element['#attributes']['type'] = $element['#type'];

marc.groth’s picture

$render = array(
  '#theme' => 'input',
  '#attributes' => array(
    'type' => 'button',
    'name' => 'button_name',
    'value' => t('Button value'),

You can then render it using the renderer service:


See the following change record for more: https://www.drupal.org/node/1886178

Maffoo’s picture

This isn't really saying what the alternative to the hook of theme_button is, though. How would one override the theme output of a button in the same way you would in D7?

cirrus3d’s picture

Using this hook on a bootstrap theme may break AJAX on Views with exposed filters (Submit/Reset buttons).

Unfortunately this seems to be a Views issue.