a() html()

A link styled as a small button, with icons; a($href, $title, $icon, $text, $class_add, $target, $no_text) or one array.

html()->a()

Options

OptionMeaning
$hrefURL; a path goes through url().
$title, $icon, $textTitle (and text by default); icon class or list of classes; text.
$class_add, $target, $no_textClasses added to CLASS_LINK_BTN; target (default _blank); icon only.
array forma(['href', 'title', 'icon', 'text', 'class', 'class_add', 'target', 'id', 'rel', 'style', 'disabled']).

Example

Code

return html()->a('/docs/html', 'Block me', 'fa fa-lock')
    . ' ' . html()->a(['href' => '/docs/html/a', 'text' => 'Same tab', 'icon' => 'fa fa-link', 'target' => '_self', 'class_add' => 'btn-primary'])
    . ' ' . a('/docs/html/icon', 'Icon only', 'fa fa-star', '', '', '_self', 1);

Notes

  • The global a() helper calls it. The text is escaped; the href is not checked: build it from site code.

Bootstrap 3 and 5

Under Bootstrap 5 a colour in class_add replaces the outline colour of the button.

See also: html/button, html/icon