---
title: core
description: Fill in a module description here
---
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

```python
import math
```

```python
__file__='../fastlucide/_icons.py'
```

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L20)

### read\_icons

```python
def read_icons():
```

```python
icons = read_icons()
```

```python
nm = 'a-arrow-down'
ico = icons[nm]
ico
```

```output
[['path', {'d': 'M3.5 13h6'}],
 ['path', {'d': 'm2 16 4.5-9 4.5 9'}],
 ['path', {'d': 'M18 7v9'}],
 ['path', {'d': 'm14 12 4 4 4-4'}]]
```

```python
svg_attrs = dict(fill='none', stroke='currentColor', stroke_width='2', stroke_linecap='round', stroke_linejoin='round')
```

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L26)

### sz\_attrs

```python
def sz_attrs(
    sz, vbox:int=24
):
```

```python
sym = [ft(t, **attrs) for t,attrs in ico]
show(Svg(*sym, **sz_attrs(24), **svg_attrs))
show(Svg(*sym, **sz_attrs(16), **svg_attrs))
```

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L32)

### symbol

```python
def symbol(
    icons, # icon dict
    nm, # Name of icon in lucide
    pre:str='', # Prefix to add to element id
):
```

*Create a [`symbol`](core.md#symbol) element for an icon*

```python
symbol(icons, nm, 'l-')
```

```html
<symbol id="l-a-arrow-down"><path d="M3.5 13h6"></path><path d="m2 16 4.5-9 4.5 9"></path><path d="M18 7v9"></path><path d="m14 12 4 4 4-4"></path></symbol>
```

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L43)

### sprites

```python
def sprites(
    icons, # icon dict
    nms, # List of lucide icon names
    pre:str='', # Prefix to add to all element ids
):
```

*SVG element containing all symbols in `nms`*

```python
sps = sprites(icons, [nm, 'accessibility'], 'l-')
show(sps)
```

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L62)

### Icon

```python
def Icon(
    nm, # Name of icon in lucide
    pre:str='', # Prefix to add to element id
    cls:str='lucide-icon', # class to use for svg
    vbox:int=24, # viewBox size (int for square, or (w,h) tuple)
    sz:int=24, # size of svg
    stroke=None, # Stroke CSS
    stroke_width=None, # Stroke width CSS
    fill=None, # Fill CSS
    trans=None, # SVG transform attribute
    **attrs
):
```

*A `use` element in an `svg` element refering to `nm`*

```python
accs = Icon('accessibility', 'l-', sz=16)
accs
```

```html
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" height="16px" width="16px" class="lucide-icon"><use href="#l-accessibility"></use></svg>
```

```python
print(accs(foo='bar'))
```

```output
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" height="16px" width="16px" class="lucide-icon" foo="bar"><use href="#l-accessibility"></use></svg>
```

```python
show(accs)
```

```python
show(Icon('accessibility', 'l-', sz=16, stroke_width=3))
```

## Transforms

Now let's add a helper function to transform Icon's with python object methods.

Using that we can define [the six svg transforms](https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/transform#transform_functions) as python instance methods.

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L99)

### Icon.rotate

```python
def rotate(
    a, cx:int=0, cy:int=0
):
```

*Rotates the element by a degrees, optionally around point (cx, cy).*

```python
show(au:=Icon('arrow-up','l-'))
show(au.rotate(45,12,12))
```

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L105)

### Icon.scale

```python
def scale(
    x, y:int=0
):
```

*Scales the element by x (and optionally y).*

Now we can also demonstrate transform chaining:

```python
show(au)
show(au.scale(0.75,0.75))
show(au.scale(0.75,0.75).rotate(45,12,12))
```

Continuing with the other transforms:

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L111)

### Icon.translate

```python
def translate(
    x, y:int=0
):
```

*Moves the element by x horizontally and optionally y vertically.*

```python
show(au)
show(au.translate(-5,-5))
```

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L122)

### Icon.skewY

```python
def skewY(
    a
):
```

*Skews the element along the Y axis by a degrees.*

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L117)

### Icon.skewX

```python
def skewX(
    a
):
```

*Skews the element along the X axis by a degrees.*

```python
show(au)
show(au.skewX(20))
show(au.skewY(20))
```

The `matrix(a, b, c, d, e, f)` transform combines all other transforms into one. The parameters map to:

- `a`, `d` — scale X and Y
- `b`, `c` — skew Y and X
- `e`, `f` — translate X and Y

Common patterns:

- `matrix(1, 0, 0, 1, tx, ty)` — translate by (tx, ty)
- `matrix(sx, 0, 0, sy, 0, 0)` — scale by (sx, sy)
- `matrix(1, tan(ay), tan(ax), 1, 0, 0)` — skew by angles ax, ay

For more details see [MDN SVG matrix transform docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/transform#matrix).

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L128)

### Icon.matrix

```python
def matrix(
    a, b, c, d, e, f
):
```

*Applies a matrix transformation with 6 values.*

Examples showing their equivalence to the other transforms:

```python
show(au.translate(5, 5))
show(au.matrix(1, 0, 0, 1, 5, 5))
```

```python
show(au.scale(0.7, 0.7))
show(au.matrix(0.7, 0, 0, 0.7, 0, 0))
```

```python
show(au.skewX(20))
show(au.matrix(1, 0, math.tan(math.radians(20)), 1, 0, 0))
```

## Combining icons

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L139)

### Icon.\_\_add\_\_

```python
def __add__(
    b
):
```

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L134)

### Icon.\_\_iadd\_\_

```python
def __iadd__(
    b
):
```

```python
ad = Icon('a-arrow-down', 'l-')
show(accs+ad)
```

```python
sps = sprites(icons, [nm, 'accessibility', 'check', 'user', 'plus', 'circle', 'file', 'arrow-up'], 'l-')
show(sps)
```

```python
show(Icon('circle', 'l-', sz=24) + Icon('check', 'l-', stroke='red'))
```

```python
show(Icon('circle', 'l-', sz=24) + Icon('check', 'l-', stroke='red').translate(2,3).scale(0.8))
```

```python
show(Icon('user', 'l-', sz=24, stroke_width=1).translate(-4, 0) +
     Icon('plus', 'l-', stroke_width=3).translate(9, 3).scale(0.6))
```

```python
show(Icon('file', 'l-', sz=24, fill='yellow') + 
     Icon('arrow-up', 'l-').translate(2,3).scale(0.7))
```

Finally, lets show we can also apply transforms to combined icons by adding a skewX to the last icon:

```python
show((Icon('file', 'l-', sz=24, fill='yellow') + 
      Icon('arrow-up', 'l-').translate(2,3).scale(0.7)).skewX(10))
```

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L145)

### SvgStyle

```python
def SvgStyle(
    cls:str='lucide-icon'
):
```

*Styles required for lucide icons to display correctly*

[source](https://github.com/AnswerDotAI/fastlucide/blob/main/fastlucide/core.py#L150)

### SvgSprites

```python
def SvgSprites(
    pre:str='', vbox:int=24, sz:int=24, cls:str='lucide-icon', nms:tuple=(), **attrs
):
```

*Create and track used icons*

```python
ss = SvgSprites('lc-', sz=18)
ss(nm)
```

```html
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" height="18px" width="18px" class="lucide-icon "><use href="#lc-a-arrow-down"></use></svg>
```

```python
show(ss('a-arrow-down'))
show(ss('accessibility', stroke_width=3))
show(ss)
```

```python
show(Style('.hover-bg:hover { background-color: aliceblue; }'))
show(ss('accessibility', sz=30, cls='hover-bg'))
```

```python
show(ss('accessibility', stroke='blue'))
```

```python
show(Div(ss('accessibility', stroke='blue'), style='background-color: aliceblue'))
```

```python
ss = SvgSprites('lc-', sz=32)
show(ss('circle', stroke='steelblue') + ss('x', stroke='crimson'))
```

```python
show(ss('arrow-up').scale(0.7).translate(8,3) +
     ss('zap', stroke='red').scale(0.5).translate(2, 19))
show(ss)
```

```python
show(ss('arrow-down').scale(0.7).translate(8,0) +
     ss('zap', stroke='red').scale(0.5).translate(2, 19))
show(ss)
```
