component-social-icons Snippet
snippets/component-social-icons.liquid renders a list of social media icons linking to URLs configured in theme settings. It conditionally displays social icons based on which social links are configured, providing icon-only links with accessible labels for screen readers. The component supports multiple social platforms including Facebook, Instagram, YouTube, TikTok, Twitter, Pinterest, Snapchat, Tumblr, and Vimeo.
What It Does
- Renders social media icons as a list of links.
- Conditionally displays icons based on theme settings.
- Provides accessible labels for screen readers.
- Supports multiple social platforms.
- Allows custom CSS class for styling.
- Uses inline SVG icons for crisp display.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
class | string | optional | Optional CSS class to append to the root <ul> element. |
Dependencies & Assets
| Type | Files / Components |
|---|---|
| CSS | External stylesheet (handled by parent components) |
| JavaScript | None required |
| Icons | icon-facebook.svg, icon-instagram.svg, icon-youtube.svg, icon-tiktok.svg, icon-twitter.svg, icon-pinterest.svg, icon-snapchat.svg, icon-tumblr.svg, icon-vimeo.svg (inline via inline_asset_content) |
| Data | Requires theme settings: social_facebook_link, social_instagram_link, social_youtube_link, social_tiktok_link, social_twitter_link, social_pinterest_link, social_snapchat_link, social_tumblr_link, social_vimeo_link |
- No external JavaScript required.
- Icons loaded inline via
inline_asset_contentfilter. - External CSS handles styling.
Dynamic Styles
The snippet does not include inline styles. All styling is handled by external CSS files. However, the component uses dynamic class names:
class="list-unstyled list-social{% if class %} {{ class}}{% endif %}"- Dynamic class: Optional class appended when provided.
Markup Structure
<ul class="list-unstyled list-social{% if class %} {{ class}}{% endif %}" role="list">
{%- if settings.social_facebook_link != blank -%}
<li class="list-social__item">
<a href="{{ settings.social_facebook_link }}" class="link list-social__link">
<span class="svg-wrapper">
{{- 'icon-facebook.svg' | inline_asset_content -}}
</span>
<span class="visually-hidden">{{ 'general.social.links.facebook' | t }}</span>
</a>
</li>
{%- endif -%}
<!-- Additional social icons -->
</ul>- Conditional rendering: Each icon only renders if corresponding setting is not blank.
- Icon wrapper: Icons wrapped in
.svg-wrapperfor styling. - Accessible labels: Each link includes visually hidden text for screen readers.
Supported Platforms
The component supports the following social platforms (each conditionally rendered):
- Facebook (
settings.social_facebook_link) - Instagram (
settings.social_instagram_link) - YouTube (
settings.social_youtube_link) - TikTok (
settings.social_tiktok_link) - Twitter (
settings.social_twitter_link) - Pinterest (
settings.social_pinterest_link) - Snapchat (
settings.social_snapchat_link) - Tumblr (
settings.social_tumblr_link) - Vimeo (
settings.social_vimeo_link)
Behavior
- Conditional display: Icons only display when corresponding theme setting is configured.
- Icon-only links: Links contain only icons (no visible text).
- Accessible: Includes visually hidden labels for screen readers.
- External links: All links point to external social media URLs.
- List structure: Uses semantic
<ul>and<li>elements.
Usage Example
Basic usage:
{% render 'component-social-icons' %}With custom class:
{% render 'component-social-icons', class: 'footer-social' %}Typically used in:
- Footer (
sections/footer.liquid) - Header (less common)
- Any component needing social media links
Implementation Notes
Theme settings: Component reads social links from theme settings (configured in theme customizer).
Conditional rendering: Each social icon only renders when its corresponding setting is not blank.
Icon dependencies: Requires the following icons in
assets/:icon-facebook.svgicon-instagram.svgicon-youtube.svgicon-tiktok.svgicon-twitter.svgicon-pinterest.svgicon-snapchat.svgicon-tumblr.svgicon-vimeo.svg
CSS class dependencies: Snippet relies on CSS classes:
.list-unstyled.list-social.list-social__item.list-social__link.link.svg-wrapper.visually-hidden
Translation keys: Uses translation keys from
locales/en.default.json:general.social.links.facebookgeneral.social.links.instagramgeneral.social.links.youtubegeneral.social.links.tiktokgeneral.social.links.twittergeneral.social.links.pinterestgeneral.social.links.snapchatgeneral.social.links.tumblrgeneral.social.links.vimeo
Accessibility features:
role="list"on<ul>for semantic structurevisually-hiddenclass for screen reader labels- Icon-only links with accessible text
Icon loading: Icons loaded inline via
inline_asset_contentfilter for immediate display.Icon wrapper: Icons wrapped in
.svg-wrapperspan for styling purposes.Link structure: Each link uses
.linkand.list-social__linkclasses for consistent styling.List structure: Uses semantic
<ul>and<li>elements for proper list structure.Custom class: Optional
classparameter appended to root<ul>for custom styling.Blank check: Each social link checked for blank value before rendering.
External links: All social links point to external URLs (no
relattributes specified).No target attribute: Links don't specify
target="_blank"(may be handled by CSS or JavaScript).Icon format: Icons must be SVG format for inline loading.
Platform order: Icons rendered in fixed order (Facebook, Instagram, YouTube, etc.).
Empty list: If no social links configured, empty
<ul>is rendered.Translation support: All platform names use translation keys for internationalization.
Visually hidden text: Platform names hidden visually but available to screen readers.
Semantic HTML: Uses proper semantic structure for accessibility.
No JavaScript: Component doesn't require any JavaScript functionality.
No inline styles: All styling handled by external CSS files.
Icon sizing: Icon sizing controlled by CSS (via
.svg-wrapperor icon classes).Link hover states: Link hover effects handled by CSS.
List styling: List uses
.list-unstyledclass to remove default list styling.Item spacing: Item spacing controlled by CSS (via
.list-social__item).Link styling: Link styling controlled by CSS (via
.linkand.list-social__link).Icon color: Icon colors controlled by CSS (likely inherits from link color).
Responsive behavior: Responsive behavior handled by CSS.
Theme setting format: Social links should be full URLs (e.g.,
https://facebook.com/username).Setting names: Theme setting names follow pattern:
social_[platform]_link.Platform support: Supports 9 social platforms total.
Extensibility: Easy to add new platforms by adding conditional block with new setting.
Icon consistency: All icons use same structure and classes for consistency.
Accessibility compliance: Meets WCAG guidelines with proper labels and semantic HTML.
Translation structure: Translation keys follow pattern:
general.social.links.[platform].No conditional logic: Simple conditional rendering - no complex logic.
Icon loading method: Icons loaded inline (not as separate HTTP requests).
SVG advantages: SVG icons provide crisp display at any size.
List role:
role="list"ensures proper screen reader announcement.Visually hidden class:
.visually-hiddenclass hides text visually but keeps it accessible.Link accessibility: Icon-only links are accessible via screen reader labels.
External link handling: External links may need
rel="noopener"for security (not in snippet).Target attribute: Links may need
target="_blank"for new tab (not in snippet, may be handled by CSS/JS).Custom class usage: Custom class allows component to be styled differently in different contexts.
Empty state: Component gracefully handles empty state (no social links configured).
Setting validation: Component assumes settings contain valid URLs (no validation in snippet).
Icon availability: Component assumes all required icons exist in assets folder.
Translation availability: Component assumes translation keys exist in locale files.
Performance: Inline SVG icons prevent additional HTTP requests but increase HTML size.