skip section navigation

Emoticon

Emoticon renders a registered emotion, a direct image or a Svelte component. use it for small artwork that carries an app-specific meaning, or leave it decorative beside text that already explains the state.

Collection saved

usage

svelte
<script>
	import { Emoticon } from '@ciabi/loafkit-ui';
	import directArtwork from '$lib/assets/emotions/happy.png';
	const src = directArtwork;
</script>

<Emoticon {src} alt="Collection saved" size="medium" />

inputs

provide emotion, src or Component. direct Component has visual priority, followed by src, then a registered definition. alt overrides a registered description. when a direct visual has no alt, it is treated as decorative. an unknown registered name with no direct visual renders nothing.

for named artwork, register an EmotionDefinition once and use its exact name. the app artwork guide covers registration, lookup, removal and how artwork reaches dialogs. no fixed set of documentation-site emotion images is bundled for consumers.

use a Svelte visual for app state

create ArtworkImage.svelte from an imported image, then pass it as the component visual.

svelte
<!-- ArtworkImage.svelte -->
<script>
	import artwork from '$lib/assets/emotions/confused.png';
	let { style = '', class: className = '' } = $props();
</script>

<img src={artwork} alt="" {style} class={className} />
svelte
<script lang="ts">
import { Emoticon } from '@ciabi/loafkit-ui';
import ArtworkImage from './ArtworkImage.svelte';
let hasBookmark = $state(false);
</script>

<button type="button" aria-pressed={hasBookmark} onclick={() => hasBookmark = !hasBookmark}>{hasBookmark ? 'remove bookmark' : 'add bookmark'}</button>
{#if hasBookmark}<p><Emoticon Component={ArtworkImage} alt="" size="small" /> bookmarked for later</p>{/if}

artwork sizes

small artwork

medium artwork

large artwork

svelte
<script lang="ts">
	import { Emoticon } from '@ciabi/loafkit-ui';
	import sizeArtwork from '$lib/assets/emotions/strawhat.png';
	const sizeImage = sizeArtwork;
</script>

{#each ['small', 'medium', 'large'] as size}
	<p><Emoticon src={sizeImage} alt="" size={size as 'small' | 'medium' | 'large'} /> {size} artwork</p>
{/each}

supply emotion, src or Component; at least one visual source is required by the public union type.

API reference

Emoticon

Component
emotion

registered artwork name.

src

direct image source, taking precedence over registered artwork.

Component

direct Svelte visual, taking precedence over image sources.

size
Default: 'medium'

the artwork size.

alt

accessible description; overrides registered alternative text.

class
Default: ''

extra classes on the component root.

style

inline styles on the component root.