Skip to Content
FeaturesCustom CSS/JS

Custom CSS and JavaScript

Add custom code to fully customise your shareable’s appearance and behaviour.

Custom code is an advanced feature. Incorrect code may break your shareable’s appearance or functionality. Test thoroughly before publishing.

Custom CSS

Add custom styles to override default styling.

Adding Custom CSS

  1. Open your shareable in the creator
  2. Go to SettingsCustom Code
  3. Enter your CSS in the Custom CSS field
  4. Click Save to apply

Many styles are applied inline by the creator. You may need to use !important to override them.

Available CSS Classes

All CSS classes use the sh- prefix. Below are the available classes organised by category.

Page Structure

ClassElement
.sh-pageMain page container
.sh-headerHeader section
.sh-header-titleHeader title
.sh-header-subtitleHeader subtitle
.sh-contentMain content area
.sh-sidebarFilter sidebar
.sh-backBack button on details page

Controls (Search, Filter, Sort)

ClassElement
.sh-controlsControls container
.sh-searchSearch wrapper
.sh-search-inputSearch input container
.sh-search-fieldSearch text input
.sh-search-iconSearch icon
.sh-search-clearClear search button
.sh-filterFilter wrapper
.sh-filter-optionFilter checkbox row
.sh-filter-checkboxFilter checkbox
.sh-filter-countActive filter count badge
.sh-sortSort wrapper
.sh-sort-wrapperSort dropdown container
.sh-sort-buttonSort button
.sh-sort-dropdownSort dropdown menu
.sh-resetReset filters button

Layout Containers

ClassElement
.sh-cardsCards layout container
.sh-listList layout container
.sh-tableTable layout container
.sh-table-headerTable header row
.sh-table-bodyTable body

Items

ClassElement
.sh-itemIndividual item (card/row)
.sh-item-coverItem cover image
.sh-item-titleItem title
.sh-item-fieldsItem fields container
.sh-show-moreLoad more button
.sh-accordion-toggleAccordion expand/collapse
.sh-accordion-contentAccordion content

Details Page

ClassElement
.sh-detailsDetails page container
.sh-details-coverDetails cover image
.sh-details-titleDetails page title
.sh-details-fieldsDetails fields container
.sh-other-items”Other items” section

Fields

ClassElement
.sh-fieldAny field container
.sh-field-textText field
.sh-field-headingHeading field
.sh-field-imageImage field
.sh-field-badgeBadge field
.sh-field-linkLink field
.sh-field-buttonButton field
.sh-field-dividerDivider field
.sh-field-labelField label
.sh-field-valueField value

UI Elements

ClassElement
.sh-badgesBadges container
.sh-badgeIndividual badge
.sh-buttonButton
.sh-linkLink
.sh-dividerDivider line

Data Attributes

In addition to CSS classes, elements have data-sh-* attributes that can be used for targeting:

AttributeDescription
data-sh-pagePage container identifier
data-sh-headerHeader element identifier
data-sh-contentContent area identifier
data-sh-itemItem identifier
data-sh-fieldField identifier
data-sh-field-typeThe type of field (text, badge, button, etc.)

Targeting with Data Attributes

/* Target all text fields */ [data-sh-field-type="text"] { font-size: 14px !important; } /* Target a specific item */ [data-sh-item="123"] { border: 2px solid gold !important; }

CSS Examples

Change Item Background

.sh-item { background-color: #f5f5f5 !important; border-radius: 12px !important; }

Style the Header

.sh-header-title { color: #1a1a1a !important; font-size: 2rem !important; } .sh-header-subtitle { color: #666 !important; }

Customise Buttons

.sh-button { background-color: #0066cc !important; border-radius: 8px !important; padding: 12px 24px !important; } .sh-button:hover { background-color: #0052a3 !important; }

Style Badges

.sh-badge { border-radius: 20px !important; font-weight: 600 !important; }

Customise Search Input

.sh-search-field { border-radius: 8px !important; border: 2px solid #ddd !important; } .sh-search-field:focus { border-color: #0066cc !important; }

Hide Elements

/* Hide the filter sidebar */ .sh-sidebar { display: none !important; } /* Hide field labels */ .sh-field-label { display: none !important; }

Custom JavaScript

Add custom scripts to extend functionality.

Adding Custom JavaScript

  1. Open your shareable in the creator
  2. Go to SettingsCustom Code
  3. Enter your JavaScript in the Custom JS field
  4. Click Save to apply

Example: Track Item Clicks

// Track when an item is clicked document.querySelectorAll('.sh-item').forEach(item => { item.addEventListener('click', () => { console.log('Item clicked:', item.dataset.shItem); // Send to your analytics }); });

Example: Listen for Load Event

// Run code when the shareable is fully loaded window.addEventListener('shareables:loaded', () => { console.log('Shareable loaded successfully'); });

Example: Custom Button Behaviour

// Add behaviour to all buttons document.querySelectorAll('.sh-button').forEach(button => { button.addEventListener('click', (e) => { // Your custom logic here console.log('Button clicked'); }); });

Best Practices

  1. Test thoroughly - Preview changes before publishing
  2. Use specific selectors - Target only the elements you need
  3. Use !important sparingly - Only when necessary to override inline styles
  4. Keep it minimal - Only add what you need
  5. Document your code - Add comments for future reference
  6. Backup first - Save your original settings before major changes
  7. Check responsiveness - Test on different screen sizes
Last updated on