Props - Svelte Flag Icons v3
Props #
All icons are extended SVGAttributes from svelte/elements.
- size = ctx.size || '24'
- role = ctx.role || 'img'
- color = ctx.color || 'currentColor'
- title
- desc
- ariaLabel = "accessibility"
- ...restProps (class, id, name, role, and all other props from SVGAttributes)
Size #
To change the size of an icon, use the size prop and specify the desired size. For example:
<Jp size="40" />
You can add a custom size using Tailwind CSS by including the desired classes in the class prop. For example:
<Jp class="h-24 w-24" />
CSS framework #
You can apply CSS framework color and other attributes directly to the icon component or its
parent tag using the class prop.
Tailwind CSS #
<Jp size="30" class="inline m-4" />
<div class="inline m-4">
<Jp size="30" />
</div>
Bootstrap #
<Jp class="position-absolute top-0 px-1" />
A11y #
Decorative Icons #
By default, icons have no aria-label. This is intentional - when icons are used next
to text or as decorative elements, they don't need labels as screen readers will ignore them.
<button>
<Jp />Japanese flag
</button>
<!-- Screen reader reads: "Japanese flag button" -->
Standalone Icons #
When icons are used without accompanying text (e.g., icon-only buttons), you should provide an
accessible label using the ariaLabel prop:
<button>
<Jp ariaLabel="View Japanese content" />
</button>
<!-- Screen reader reads: "View Japanese content button" -->
Rich Descriptions #
For complex icons that need detailed descriptions, use title and desc props.
The title provides a short label, while desc offers a longer description:
<Jp
title={{ id: 'my-title', title: 'Japanese flag icon' }}
desc={{ id: 'my-descrip', desc: 'Red sun on white field, simple design for easy recognition.' }}
ariaLabel="Japanese flag"
/>
Note: When using title, you don't need ariaLabel as the
title will be used automatically via aria-labelledby.
Focusable #
Icons are not keyboard-focusable by default (focusable="false"). If you need to
change this behavior, use the focusable prop:
<Jp focusable="true" />
Passing down other attributes #
Since all icons have ...restProps, you can pass other SVGAttributes.
<Jp
id="my-svg"
transform="rotate(45)"
class="hover:cursor-pointer dark:text-white"
onclick={() => alert('hello')}
/>