Icons
heyo-ui ships no icon dependency. Every icon prop takes a component, an element, or any node.
Loading documentation…
heyo-ui has no icon dependency. An icon set is a taste decision with a measurable bundle cost, and a component library that picks one for you is a component library you fight the first time your product standardises on something else.
icon prop acceptsThree shapes, interchangeable everywhere:
| Shape | Example | When |
|---|---|---|
| A component | icon={IconPlus} | The common case. The control sizes and colours it |
| An element | icon={<IconPlus />} | When you need props of your own — a stroke width, a className |
| Any node | icon={<span>🙂</span>} | An emoji, an image, a <span>. Nothing about the prop is icon-specific |
The two dozen glyphs the components need for themselves — chevrons, check
marks, the spinner, the clear button — are inlined verbatim from
Tabler Icons: a 24×24 grid, 2px stroke, round caps
and joins. They sit flush with @tabler/icons-react if you use it for the
rest of your interface, and they cost nothing if you do not.
The chevron above is one of them. You never pass it, and you cannot remove it — it is part of what makes the control a select.
Everything that renders a row takes an icon:
Button · Badge · Input · Textarea · Toggle · Tabs · Dropdown ·
Command · Tree · Timeline · Stat · Empty · CodeBlock ·
FileUpload · Sidebar.MenuButton · Sidebar.MenuSubButton ·
Accordion.Trigger · Breadcrumb crumbs · Combobox options
Do not size an icon yourself. The control decides: a sm button gets a 14px
glyph, a base button 16px, a sidebar row 16px, a badge 12px. Passing a sized
icon in defeats the alignment the control is maintaining between its label, its
glyph and its neighbours.
renderIcon is the helper the components use internally. Reach for it when you
build a component of your own that should accept the same prop shape.
It takes the icon and a class: the class is applied to a component or element icon, and ignored for a plain node.