PHP code example of ui-awesome / html-svg

1. Go to this page and download the library: Download ui-awesome/html-svg library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ui-awesome / html-svg example snippets


use UIAwesome\Html\Graphic\Svg;

echo Svg::widget()
    ->class('hidden')
    ->filePath(__DIR__ . '/svg/moon.svg')
    ->fill('currentColor')
    ->height(32)
    ->id('theme-toggle-dark-icon')
    ->width(32);

$svg = Svg::widget();

// setting class attribute
$svg->class('container');

$svg->attributes(['class' => 'container', 'style' => 'background-color: #eee;']);

$svg->content('MyContent');

$html = $svg->render();

$html = (string) $svg;

// adding multiple attributes
$svg->class('external')->content('MyContent');

// setting the file path for the `HTML` output
$svg->filePath('/path/to/file')->render();