You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 7, 2025. It is now read-only.
Then, don't forget to autoload your Composer packages!
24
-
25
-
```php
26
-
require 'vendor/autoload.php';
27
-
```
28
-
29
15
## Usage
30
16
31
-
### Get an icon
17
+
### Icons
18
+
19
+
`Icons` are retrieved from an `IconManager`.
32
20
33
21
```php
34
22
<?php
35
-
require 'vendor/autoload.php';
36
-
$icons = new Feather\Icons();
23
+
$icons = new \Feather\IconManager();
37
24
?>
38
25
39
-
<!-- Display the 'anchor' icon !-->
40
-
<?php echo $icons->get('feather'); ?>
26
+
<!-- Display the 'anchor' icon -->
27
+
<?php echo $icons->getIcon('anchor'); ?>
41
28
42
-
<!-- Get creative! !-->
43
-
<buttonclass="icon-button">Learn More <?php echo $icons->get('arrow-right'); ?></button>
29
+
<!-- Get creative! -->
30
+
<buttonclass="icon-button">
31
+
Learn More <?= $icons->getIcon('arrow-right'); ?>
32
+
</button>
44
33
```
45
34
46
-
### Get an icon with modified properties
47
-
48
-
Simply pass an array with the attributes you want. This will be merged over the `Icons` class default attributes, except for `class`, which gets concatenated to the default classes.
You can also change the default attributes in the `Icons` class if you want some attributes consistent across multiple `get` calls. The passed attributes are merged over the current attributes in the
56
-
class by default.
35
+
`Feather\IconManager::getIcon()` returns an `Icon` object. To render the icon html itself, either cast the `Icon` as a string or call its `render()` function.
$icons->getIcon('anchor'); // Returns an Icon object
39
+
$html = $icons->getIcon('anchor')->render(); // Returns the icon's html
40
+
echo $icons->getIcon('anchor'); // Outputs the icon's html, since it is cast as a string
66
41
```
42
+
### Attributes
67
43
68
-
## API
44
+
Attributes can be modified on both the `IconManager` and on `Icon` objects. Attributes can be modified directly using the `setAttribute(s)` functions or by using the helper functions.
69
45
70
-
### `Feather\Icons`
71
-
72
-
Usage:
46
+
Attribute changes on the `IconManager` will affect all `Icon` objects created by the `IconManager`. Changes on `Icon` objects will only affect the individual icons.
73
47
74
48
```php
75
-
$icons = new Feather\Icons();
76
-
```
77
-
78
-
<br>
49
+
// Use on the IconManager instance to set default attributes for all icons
Sets default attributes of the class. These are used as default attributes for the `get` method. By default, the `$attributes` argument is merged over the current attributes in the class. You can
108
-
disable this by setting the `$merge` argument to false, but only do it if you know what you are doing.
64
+
When getting an `Icon`, alt text can be passed as an argument or can be set on the `Icon` at a later time.
109
65
110
66
```php
111
-
$icons = new Feather\Icons();
112
-
113
-
// Set some default attributes (this will be merged with the current defaults in the class)
|$merge? |boolean|Whether to merge with the current attributes (true) or replace them (false)|
127
-
128
-
<br>
129
-
130
-
### `Feather\Icons->getAttributes()`
131
-
132
-
Get the current attributes for the class. To set it, use the `setAttributes()` method;
74
+
Aliases can be set to make larger changes across a theme easier, such as replacing the actual icon used for a specific use case. For example, what if for the close button icon, you wanted to switch
75
+
from using the `x` icon to `x-circle`. Instead of having the icon name hardcoded, you could use an alias for the use case and update the value in one place. Aliases are set on the `IconManager`.
133
76
134
77
```php
135
-
$icons = new Feather\Icons();
136
-
137
-
$attrs = $icons->getAttributes();
138
-
```
139
-
140
-
<br>
141
-
142
-
### `Feather\DEFAULT_ATTRIBUTES`
143
-
144
-
Constant array of default attributes. They are applied to every new `Icons` class. You can use this to reset the attributes of an `Icons` class.
145
-
146
-
```php
147
-
$icons = new Feather\Icons();
148
-
149
-
// Add/modify some default attributes
150
-
$icons->setAttributes( ... );
151
-
152
-
// ... do some stuff ...
153
-
154
-
// Now say you want to reset the attributes you modified to the default...
155
-
// Set merge to false to overwrite instead of merge the arrays
0 commit comments