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
- Open your shareable in the creator
- Go to Settings → Custom Code
- Enter your CSS in the Custom CSS field
- 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
| Class | Element |
|---|---|
.sh-page | Main page container |
.sh-header | Header section |
.sh-header-title | Header title |
.sh-header-subtitle | Header subtitle |
.sh-content | Main content area |
.sh-sidebar | Filter sidebar |
.sh-back | Back button on details page |
Controls (Search, Filter, Sort)
| Class | Element |
|---|---|
.sh-controls | Controls container |
.sh-search | Search wrapper |
.sh-search-input | Search input container |
.sh-search-field | Search text input |
.sh-search-icon | Search icon |
.sh-search-clear | Clear search button |
.sh-filter | Filter wrapper |
.sh-filter-option | Filter checkbox row |
.sh-filter-checkbox | Filter checkbox |
.sh-filter-count | Active filter count badge |
.sh-sort | Sort wrapper |
.sh-sort-wrapper | Sort dropdown container |
.sh-sort-button | Sort button |
.sh-sort-dropdown | Sort dropdown menu |
.sh-reset | Reset filters button |
Layout Containers
| Class | Element |
|---|---|
.sh-cards | Cards layout container |
.sh-list | List layout container |
.sh-table | Table layout container |
.sh-table-header | Table header row |
.sh-table-body | Table body |
Items
| Class | Element |
|---|---|
.sh-item | Individual item (card/row) |
.sh-item-cover | Item cover image |
.sh-item-title | Item title |
.sh-item-fields | Item fields container |
.sh-show-more | Load more button |
.sh-accordion-toggle | Accordion expand/collapse |
.sh-accordion-content | Accordion content |
Details Page
| Class | Element |
|---|---|
.sh-details | Details page container |
.sh-details-cover | Details cover image |
.sh-details-title | Details page title |
.sh-details-fields | Details fields container |
.sh-other-items | ”Other items” section |
Fields
| Class | Element |
|---|---|
.sh-field | Any field container |
.sh-field-text | Text field |
.sh-field-heading | Heading field |
.sh-field-image | Image field |
.sh-field-badge | Badge field |
.sh-field-link | Link field |
.sh-field-button | Button field |
.sh-field-divider | Divider field |
.sh-field-label | Field label |
.sh-field-value | Field value |
UI Elements
| Class | Element |
|---|---|
.sh-badges | Badges container |
.sh-badge | Individual badge |
.sh-button | Button |
.sh-link | Link |
.sh-divider | Divider line |
Data Attributes
In addition to CSS classes, elements have data-sh-* attributes that can be used for targeting:
| Attribute | Description |
|---|---|
data-sh-page | Page container identifier |
data-sh-header | Header element identifier |
data-sh-content | Content area identifier |
data-sh-item | Item identifier |
data-sh-field | Field identifier |
data-sh-field-type | The 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
- Open your shareable in the creator
- Go to Settings → Custom Code
- Enter your JavaScript in the Custom JS field
- 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
- Test thoroughly - Preview changes before publishing
- Use specific selectors - Target only the elements you need
- Use
!importantsparingly - Only when necessary to override inline styles - Keep it minimal - Only add what you need
- Document your code - Add comments for future reference
- Backup first - Save your original settings before major changes
- Check responsiveness - Test on different screen sizes
Last updated on