Foundation Buttons

This namespace contains Foundation buttons and buttongroups. They are convenient tools when a centralized style for customized button links and form buttons etc. isneeded.

The ButtonInterface For Foundation styled button

Interface defines required minimun implementation for all Foundation styled Buttons. Buttons support predefined Foundation color and size classes and can also use custom made classes. Colors can be set by calling ButtonInterface::setColor() instance method whereas size can be set by calling ButtonInterface::setSize() instance method with the CSS class name as a parameter value:

Predefined color classes:

  • NULL unsets all special button styles (default)
  • 'alert' for alert/error buttons
  • 'success' for ok/success buttons
  • 'info' for information buttons
  • 'secondary' for alternatively styled buttons
  • 'disabled' for disabled buttons

Predefined size classes:

  • 'tiny' for tiny buttons
  • 'small' for small buttons
  • NULL for medium buttons (default)
  • 'large' for large buttons
  • 'extend' for extended buttons (takes the full width of the container) "

Button Converts anything to button style

This adapter can transform most Component objects to Foundation styled buttons.

  • PHP code
    1. <?php
    3. namespace Sphp\Html\Foundation\Sites\Buttons;
    5. $b1 = Button::hyperlink("", "Google", "engine")
    6.         ->setSize("small")
    7.         ->setColor("alert");
    8. $b2 = Button::hyperlink("", "Bing", "engine")
    9.         ->setSize("medium")
    10.         ->setColor("warning")
    11.         ->disable(true);
    12. $b3 = Button::hyperlink("", "", "engine")
    13.         ->setSize("large")
    14.         ->setColor("success")
    15.         ->isHollow(true);
    16. $b4 = Button::submitter("Submit!", "submit", "foo")
    17.         ->setColor("secondary")
    18.         ->isDropdown(true);
    20. echo "$b1 $b2 $b3 $b4";
    Highlighted with GeSHi
  • Execution result as HTML5 flow

The ButtonGroup class

A ButtonGroup component is a container for ButtonInterface components. A ButtonGroup component is effective for displaying a group of actions in a bar. ButtonGroup component works perfectly with the grid component.

The orientation of a button group can be changed with method ButtonGroup::stackFor() that uses Foundation stack classes for button groups. Stacking can be removed by using ButtonGroup::unStackFor() method.

  • PHP code
    1. <?php
    3. namespace Sphp\Html\Foundation\Sites\Buttons;
    5. $buttonGroup = new ButtonGroup();
    6. $buttonGroup->appendButton(new \Sphp\Html\Span("foo button"));
    7. $buttonGroup->appendButton(Button::hyperlink("", "google", "engine"));
    8. $buttonGroup->appendButton(Button::hyperlink("", "Bing", "engine"));
    9. $buttonGroup->appendHyperlink("", "Yahoo!", "engine");
    10. $buttonGroup->setSize("tiny");
    12. $buttonGroup->printHtml();
    14. $buttonGroup->setExtended(true);
    15. $buttonGroup->printHtml();
    17. use Sphp\Html\Foundation\Sites\Containers\Dropdown;
    19. $split = (new ButtonGroup())->setSize('small');
    20. $split->appendPushButton('Push button')->setColor('alert');
    21. $opener = $split->appendArrowOnlyButton('Dropdownopener');
    23. $dd = new Dropdown($opener, "Hello! I'm a dropdown");
    25. echo "$split {$dd->getDropdown()}";
    27. $buttonGroup->setColor("success");
    28. $buttonGroup->printHtml();
    30. $buttonGroup->stackFor("all")
    31.         ->printHtml();
    Highlighted with GeSHi
  • Execution result as HTML5 flow