Developer Documentation
The Listonic Add-to-List button allows users to add ingredients or shopping items directly to their Listonic shopping list. It works on any website or web application and requires only a few lines of JavaScript.
2-Minute Setup
Get your shopping list button running in three simple steps.
data-items attribute
<!-- Listonic Add-to-List Button -->
<div class="listonic-button"
data-items="Milk, Eggs, Bread"
data-name="My Shopping List">
</div>
<script src="widget/listonic-button.js" defer></script>
Overview & Benefits#
The Add-to-List integration is designed to be lightweight and easy to embed. You can use it in two main ways, depending on your use case:
- Custom Button – Ideal for predefined item lists. You have full control over which items are added.
- Automatic Button – Automatically extracts items from your HTML structure. Perfect for recipe blogs and structured content.
Both methods use a simple JavaScript snippet and hosted scripts provided by Listonic. You can start with the Custom Button for maximum control, or the Automatic Button to automatically convert existing ingredient lists into Add-to-List buttons.
Listonic is used by over 20 million users worldwide and supports 40+ languages. Your visitors get a native shopping list experience automatically.
Custom Button Parameters#
The items to be added to the shopping list. Separate items using commas. HTML links with <a> tags are supported within items.
The default name for the shopping list. If not provided, the user can choose or create a list in the Listonic interface.
A JSON object with styling properties. Available properties: primaryColor, iconColor, textColor, borderRadius, border, padding, buttonText, fontFamily, fontSize, fontWeight, fontStyle, iconStyle, iconHidden, iconPosition, customCSS.
Automatic Button Parameters#
The Automatic Button is configured using the listonic_auto object. Set its properties before loading the script.
The CSS class name of the HTML element containing your ingredient list. The widget will scan this element for list items.
The minimum number of items required before the button is shown. Useful for filtering out containers with too few items.
Set to true to hide the sidebar and use a more compact display mode. Defaults to false.
A style object applied to all auto-generated buttons. Supports the same properties as data-style (e.g. primaryColor, borderRadius, fontFamily).
Button Styling#
Customize the look and feel of your Listonic button using the data-style attribute. Pass a JSON object with the styling properties you want to override.
Custom Styling#
Use the data-style attribute on any button element to apply custom styles:
<div class="listonic-button"
data-items="Milk, Eggs, Bread"
data-name="My List"
data-style='{
"primaryColor": "#FF6B35",
"iconColor": "#ffffff",
"textColor": "#ffffff",
"borderRadius": "50px",
"fontFamily": "Roboto, sans-serif",
"fontSize": "16px",
"fontWeight": "600",
"buttonText": "Add to shopping list",
"iconStyle": "shopping-cart"
}'>
</div>
<script src="widget/listonic-button.js" defer></script>
Available Style Properties
| Property | Description |
|---|---|
primaryColor |
Main button background color |
iconColor |
Icon fill color |
textColor |
Button text color |
borderRadius |
Button border radius (e.g. "50px", "8px") |
border |
CSS border value (e.g. "2px solid #ccc") |
padding |
Button padding |
buttonText |
Custom button label text |
fontFamily |
Font family for button text |
fontSize |
Font size for button text |
fontWeight |
Font weight for button text |
fontStyle |
Font style (e.g. "italic") |
iconStyle |
Icon type: "clipboard-check", "shopping-cart", "list", "plus", or "check" |
iconHidden |
Set to true to hide the icon |
iconPosition |
Set to "right" to move icon after text |
customCSS |
Raw CSS string for advanced customization |
Dynamic Content (AJAX/SPAs)#
If you inject content dynamically (for example, via AJAX or a frontend framework), you can create and initialize Listonic buttons programmatically using the ListonicButton.initButton API.
// After your content is loaded via AJAX
function addListonicButton(items, listName, containerId, style) {
const container = document.getElementById(containerId);
// Create button element with data attributes
const el = document.createElement('div');
el.className = 'listonic-button';
el.dataset.items = items.join(', ');
el.dataset.name = listName;
if (style) {
el.dataset.style = JSON.stringify(style);
}
container.appendChild(el);
// Initialize the button via the public API
if (window.ListonicButton) {
window.ListonicButton.initButton(el);
}
}
Make sure the widget/listonic-button.js script is already loaded before calling ListonicButton.initButton(). The script must be included once on the page.
Framework Integration#
The following examples show how to integrate Listonic buttons with popular JavaScript frameworks. These components use the v2 data-* attributes and ListonicButton.initButton API.
When using frameworks: (1) Load widget/listonic-button.js once (e.g. in your HTML or via a script loader), (2) Use data-* attributes on div elements, (3) Call ListonicButton.initButton(el) after the element is in the DOM.
React
import React, { useEffect, useRef } from 'react';
const ListonicButton = ({ items, name, style }) => {
const ref = useRef(null);
useEffect(() => {
if (ref.current && window.ListonicButton) {
window.ListonicButton.initButton(ref.current);
}
}, [items, name]);
return (
<div
ref={ref}
className="listonic-button"
data-items={items}
data-name={name}
data-style={style ? JSON.stringify(style) : undefined}
/>
);
};
export default ListonicButton;
Vue.js
<template>
<div ref="buttonEl"
class="listonic-button"
:data-items="items"
:data-name="name"
:data-style="styleJson"></div>
</template>
<script>
export default {
props: {
items: { type: String, required: true },
name: { type: String, default: 'Shopping List' },
style: { type: Object, default: null }
},
computed: {
styleJson() {
return this.style ? JSON.stringify(this.style) : undefined;
}
},
mounted() {
if (window.ListonicButton) {
window.ListonicButton.initButton(this.$refs.buttonEl);
}
}
}
</script>
Platform Guides#
WordPress
- In the Gutenberg editor, add a "Custom HTML" block where you want the button
- Paste the complete Listonic button code into the block
- For the script, use a plugin like "Insert Headers and Footers" to add it site-wide, or include it in the Custom HTML block
Shopify
- Go to Online Store → Themes → Edit code
- Add the button HTML to your product template (
product-template.liquid) - Add the Listonic script to
theme.liquidbefore</body>
Wix
- Add an "Embed" or "HTML iframe" element to your page
- Paste the complete button code including the script
- Adjust the element size to fit the button
Squarespace
- Add a "Code" block to your page
- Paste the complete Listonic button code
- Save and preview the page
Troubleshooting#
Common Issues
Button doesn't appear
- Ensure the script URL is correct and accessible
- Check that the container element has the class
listonic-button - Verify there are no JavaScript errors in the console
- Make sure
data-itemsis set on the element before the script loads
Items not being added
- Check that items are separated by commas in the
data-itemsattribute - Ensure the content doesn't contain invalid HTML
- For the automatic button, verify the
entryClassinlistonic_automatches your HTML
Multiple buttons conflict
- Use separate
<div class="listonic-button">elements for each button - Include the script only once on the page
Browser Compatibility
The Listonic widget supports all modern browsers:
- Chrome (desktop and mobile)
- Firefox
- Safari (desktop and iOS)
- Edge
The widget uses standard JavaScript functionality supported by all modern browsers.
Debugging Tips
- Open browser DevTools (F12) and check the Console for errors
- Inspect the button element to ensure it has the correct
data-*attributes - Verify the public API is available: type
window.ListonicButtonin the console - Check Network tab to ensure the script loaded (200 status)
Best Practices#
Performance & Script Placement
- Place the script tag with
deferattribute so it does not block initial page rendering - For pages with many buttons, use separate
<div class="listonic-button">elements — the script handles them all - Load the Listonic script only once per page, even when using multiple buttons
HTML Structure Guidelines
- Keep ingredient lists in clean, semantic HTML structures (for example, unordered lists with list items) so the widget can parse them reliably
- Use consistent class names across your recipe pages
- Avoid nesting interactive elements inside list items
Accessibility
- The button is rendered as a native HTML element, accessible to screen readers
- Ensure sufficient color contrast if customizing colors
- The button is keyboard-navigable by default
Dynamic Content
- If you inject content dynamically (via AJAX or a frontend framework), use
ListonicButton.initButton(el)to initialize new button elements after they are added to the DOM - When using multiple buttons, each
<div class="listonic-button">element is independent — no special configuration needed - Test your integration on both desktop and mobile devices to ensure a smooth user experience
API Reference#
Custom Button API
| Attribute / API | Type | Required | Description |
|---|---|---|---|
data-items |
string | Yes | Comma-separated list of items |
data-name |
string | No | Default list name |
data-style |
JSON string | No | JSON object with styling properties |
ListonicButton.init() |
function | No | Re-initialize all buttons on the page |
ListonicButton.initButton(el) |
function | No | Initialize a single button element |
Automatic Button API
| Property | Type | Required | Description |
|---|---|---|---|
listonic_auto.entryClass |
string | Yes | CSS class of ingredient container |
listonic_auto.minCount |
number | No | Minimum items to show button |
listonic_auto.hideSideBar |
boolean | No | Hide sidebar for compact mode |
listonic_auto.style |
object | No | Style object applied to auto-generated buttons |
Script URLs
| Widget Type | URL |
|---|---|
| Custom Button | widget/listonic-button.js |
| Automatic Button | widget/listonic-auto.js |
Frequently Asked Questions#
Installation Questions
Can I use the widget on any website?
Yes! The widget works on virtually any website or web application, including WordPress, Shopify, custom HTML sites, and modern JavaScript frameworks. As long as you can insert JavaScript into the page, you can use the Listonic Add-to-List button.
Do I need an API key?
No, the Listonic widget is free to use and doesn't require any API key or registration.
Is there a limit to how many buttons I can add?
No, you can add as many buttons as needed. Just use separate <div class="listonic-button"> elements — the script initializes them all automatically.
Customization Questions
Can I customize the button appearance?
Yes, you can customize colors and other styles using the data-style attribute. See the Styling section for all available properties. You can also use the Widget generator for a visual editor.
Can I change the button text?
Yes, use the buttonText property in the data-style attribute to set any custom label, for example: data-style='{"buttonText":"Add to shopping list"}'.
Technical Questions
Is the widget mobile-friendly?
Yes, the widget is fully responsive and works seamlessly on mobile devices. It connects directly with the Listonic app, which is used by over 20 million users worldwide.
Does the widget affect page load speed?
The widget is lightweight. The script uses the defer attribute, so it loads without blocking initial page rendering.
What happens when a user clicks the button?
The button opens the Listonic interface where users can add items to their shopping list. If they have the Listonic app, items sync automatically across their devices.
Live Examples#
Recipe Blogs & Websites
Recipe websites and food bloggers use our buttons to help readers instantly save ingredients to their shopping lists.
Automatic ingredient extraction, one-click recipe saving, and perfect for meal planning.
View demo →Travel Guides & Blogs
Travel websites help readers prepare for trips by saving packing lists, local shopping items, and destination essentials.
Destination packing lists, local market shopping guides, and travel essentials reminders.
View demo →Fitness Blogs & Wellness Sites
Fitness websites help readers save meal prep ingredients, supplement lists, and healthy eating shopping guides.
Meal prep shopping lists, nutrition plan ingredients, and supplement recommendations.
View demo →Teacher Resources & Educational Sites
Educational platforms help teachers share classroom supply lists, project materials, and student resources with parents.
Classroom supply lists, project material lists, and parent-teacher sharing.
View demo →Use our interactive Widget generator to create custom-styled buttons with live preview and copy-ready code.