PHP Controls Bootstrap controls for PHP

\Bootstrap\Components\Button

Code
$button = new \Bootstrap\Components\Button('Touch Me!');
$button->id('my-button')->type('input')->class('bg-success-50');
$button->printHtml();
Result

Documentation

\Bootstrap\Components\Button

A component that enables you to easily write <button> control through PHP.

Usage

Instantiate the Button by passing a content.

$button = new \Bootstrap\Components\Button('Touch Me!');

// continued below...

Options

Button::options

Option Default Description
disabled false If the control is disabled

Example:

// during init
$button = new \Bootstrap\Components\Button('Touch Me!', ['disabled' => true]);

// after init
$button->options('disabled', true);

Other properties

  • Button::content - The content of the button
  • Button::icon - Sets the icon
  • Button::type - Sets the type attribute
  • Button::container - Sets the container/wrapper (default <button>)
  • Button::size - Sets the size (lg, sm, etc.)
  • Button::attr - Sets additinoal attributes
  • Button::id - Sets the id attribute
  • Button::class - Sets the class attribute

Styling

To learn more about styling the <button>, see UI Buttons demo.

Print

Finally, once you configured your button, you can now htmlPrint it!

$button->printHtml();

Credits

\Bootstrap\Components\Button is part of the lodev09/bootstrap-php package created by @lodev09.