Hand-written Includes in-depth notes
Icon ry_icon
Components and page templates
Inline SVG icon that needs no icon font and no extra file request.
ry_icon($name, $size = 24, $class = '')
Pages Home List pages Detail pages Single pages Site-wide (system)
How do I read these repository paths?
All paths are relative to the site root. Open core/tpl_blocks.php at line 100 to see the definition of ry_icon(). The "core method" is what the tag actually forwards to: a template writes content_list(...) and the core runs Tpl::contentList(...).
1. Fill in parameters, get the code Edit any field and the result below updates instantly; press Copy and paste it into a template. It also works without JavaScript: press Generate and the server recomputes it.
click the title to collapse / expand
Now generating: ry_icon
This is the real rendering of the page (real header, container, this tag output, real footer). It reloads when you change a parameter.
Refreshing…
This is the server-computed default; it updates as you edit any parameter and the preview on the right is re-rendered too. It also works without JavaScript: fill the form and press Generate.
2. Full parameter table 3 parameters, one per row; scroll sideways on narrow screens.
click the title to collapse / expand
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
string |
required / as needed | Required icon name, for example phone or download; a name found in neither icon table falls back to boxes. |
size |
int |
24 | 0 or a negative value counts as unset and still renders at the default 24. |
class |
string |
'' | Extra class; ry-svg-icon is always present, so this only appends. |
3. Examples Every example can be copied as-is; the later ones are more advanced.
click the title to collapse / expand
Minimal
Renders at the default 24px and inherits both colour and line height from the parent.
<?= ry_icon('phone') ?>
Common: contact lines
18px keeps the icons aligned with body text, and the tag emits no wrapper, so this paragraph owns the spacing.
<p class="ry-contact-line">
<?= ry_icon('phone', 18) ?> 400-000-0000
<?= ry_icon('mail', 18) ?> service@example.com
</p>
Advanced: one size per role
ry-btn ships with the base styles, while ry-card__icon and ry-empty__icon are classes from your own template pack.
<?php /* card badge, empty state and button arrow each get their own size */ ?>
<span class="ry-card__icon"><?= ry_icon('download', 20) ?></span>
<span class="ry-empty__icon"><?= ry_icon('file', 44) ?></span>
<a class="ry-btn" href="/downloads/"><?= ry_icon('arrow-right', 14) ?> Download</a>
4. What it does / when to use it
Use it wherever a small monochrome icon belongs next to text: a contact line in the footer, a download button, a card corner badge, or an empty state message. It renders an inline SVG, so there is no icon font to load, no extra HTTP request, and nothing to break when a font CDN is blocked. It is not a replacement for real artwork: the output is a single-stroke line icon that takes the surrounding text colour, so multi-colour illustrations and brand marks still need an image.
5. Which pages it belongs on This is the question clients actually ask: "I am building the home page / a list page / a detail page — which tags do I use?"
click the title to collapse / expand
| Page | What that page is | What this tag does there |
|---|---|---|
| Home | Home page: hero, category blocks, latest content |
On the home page it usually sits in the hero, a category block, or a latest/featured section. You use it to: Use it wherever a small monochrome icon belongs next to text: a contact line in the footer, a download button, a card co |
| List pages | Category list pages: listing, filters, pagination |
On a list page it lives in the list container or right next to the pagination bar. You use it to: Use it wherever a small monochrome icon belongs next to text: a contact line in the footer, a download button, a card co |
| Detail pages | Content detail pages: body, specs, related items |
On a detail page it goes in the body area or in the related-items sidebar. You use it to: Use it wherever a small monochrome icon belongs next to text: a contact line in the footer, a download button, a card co |
| Single pages | One-off pages such as About or Contact |
On a single page (About, Contact) it sits inside the content block. You use it to: Use it wherever a small monochrome icon belongs next to text: a contact line in the footer, a download button, a card co |
| Site-wide (system) | Header, footer, head, styles and scripts — every page template needs them |
It is a system tag written once per page template, inside the page shell (head, header, footer, scripts). You use it to: Use it wherever a small monochrome icon belongs next to text: a contact line in the footer, a download button, a card co |
Clicking a page name jumps to every tag for that page in the reference (the "By page" filter there). This page always shows everything about the tag, whatever that filter is set to.
6. How to use it (step by step)
- Pick a semantic name such as
phone, mail, download, or arrow-right. Semantic names stay stable, so you rarely need to know the underlying path.
- Start from
<?= ry_icon('download') ?>, which renders at 24px. The icon inherits the current text colour, so check the colour of the parent element first.
- Tune the size to the surrounding density: 14 to 18px for inline labels and button arrows, 18 to 22px for card badges, and 36 to 48px for empty states.
- Pass a class as the third argument when the icon needs its own colour, rotation, or spacing, for example
ry_icon('arrow-right', 16, 'is-link-arrow'), then style that class in your template pack instead of adding inline styles.
- Combine the icon with text on one line,
<?= ry_icon('phone', 18) ?> 400-000-0000, and control the gap from the parent with flex and gap rather than keyboard spaces.
phone, mail, download, or arrow-right. Semantic names stay stable, so you rarely need to know the underlying path.<?= ry_icon('download') ?>, which renders at 24px. The icon inherits the current text colour, so check the colour of the parent element first.ry_icon('arrow-right', 16, 'is-link-arrow'), then style that class in your template pack instead of adding inline styles.<?= ry_icon('phone', 18) ?> 400-000-0000, and control the gap from the parent with flex and gap rather than keyboard spaces.7. Common pitfalls
- An unknown name fails silently and falls back to the generic block icon. When you change an icon, reload the page and confirm the shape actually changed instead of trusting the absence of an error.
- Expecting the tag to choose a colour: the stroke uses
currentColor, so an icon inside grey text renders grey. Set the colour on the parent or on the class you pass.
- Shipping an icon-only link: the SVG carries aria-hidden, so screen readers announce nothing and the link ends up with no accessible name. Add an aria-label or visually hidden text for icon-only controls.
- Passing zero or a negative size: a value that is not greater than zero counts as unset and still renders at 24px.
- Using it as a large decorative graphic: the viewBox is 24 by 24, so a 200px render shows very thin strokes. Use a real image wherever artwork is needed.
Note from the reference table In a template ry_icon() is the only icon function registered (Blocks::icon() is the core static method and the admin has its own Layout::icon(), and neither is available to templates). The quick sheet now uses ry_icon(...) everywhere, so copying it works. Also, name is required in code and has no default, so omitting it raises ArgumentCountError rather than falling back to an empty value.
currentColor, so an icon inside grey text renders grey. Set the colour on the parent or on the class you pass.ry_icon() is the only icon function registered (Blocks::icon() is the core static method and the admin has its own Layout::icon(), and neither is available to templates). The quick sheet now uses ry_icon(...) everywhere, so copying it works. Also, name is required in code and has no default, so omitting it raises ArgumentCountError rather than falling back to an empty value.8. Real rendered output This section was rendered once on the server with this site real data; it is not a mock-up.
click the title to collapse / expand
An inline SVG icon (ry_icon('download', 24)). It inherits the text colour.
Loading the code…
9. Where it already appears in your templates Grouped by components / page templates / template packs; the data comes from a script scan.
click the title to collapse / expand
Components 155 files / 389 calls 89% of tag calls live in components
-
templates/_shared/components/detail-content-download.php×10 lines 409, 538, 543, 564, 582, 590… -
templates/_shared/components/detail-content-gallery-masonry.php×9 lines 344, 360, 368, 375, 382, 394… -
templates/_shared/components/detail-pkg.php×9 lines 313, 336, 387, 401, 460, 470… -
templates/_shared/components/detail-content-download-table.php×8 lines 468, 548, 555, 572, 581, 589… -
templates/_shared/components/detail-content-faq-side.php×8 lines 182, 190, 193, 197, 209, 214… -
templates/_shared/components/detail-content-video-player.php×8 lines 572, 634, 643, 657, 663, 675… -
templates/_shared/components/detail-content-video.php×8 lines 408, 626, 635, 648, 664, 677… -
templates/_shared/components/detail-content-advantage.php×7 lines 236, 238, 248, 251, 266, 281…
Page templates 4 files / 14 calls
-
templates/_shared/member_levels.php×7 lines 99, 139, 146, 153, 157, 161… -
templates/_shared/member.php×3 lines 139, 170, 203 -
templates/_shared/member_buy_pkg.php×3 lines 110, 111, 112 -
templates/_shared/member_buy.php×1 lines 89
Click "See this code + preview": the left shows the real code around that call site (±12 lines, call line highlighted) and the right renders a real page preview with the current parameters.
Common combinations (generated from your real templates)
- The page template hosting this tag is member_levels
templates/_shared/member_levels.php
templates/_shared/member_levels.php
At a glance
ry_icon
Home / List pages / Detail pages / Single pages / Site-wide (system)