SolidJS Components
Show
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Required |
- |
Item display condition. |
|
|
|
Optional |
- |
Renders its content if the condition in |
<Show
when={context.count > 3}
fallback={<div>I will be rendered if context.count is <= 3</div>}
>
<div>I will be rendered if context.count is > 3</div>
</Show>
<Show
when={context.count > 3}
fallback={"string also valid"}
>
<div>I will be rendered if context.count is > 3</div>
</Show>
For
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Required |
- |
The array you want to expand. |
|
|
|
Optional |
- |
Renders its content if the array is empty. |
<ul>
<For
each={context.termList}
fallback={<div class="term-list-placeholder">Loading</div>}
>
{(item, index) => (
<li class="term-item" onClick={(e) => context.ding(item)}>
{index() + ". " + JSON.stringify(item.name)}
</li>
)
}
</For>
</ul>
The function inside For has 2 arguments:
-
item - array item
-
index - getter for index, to get index call
index()
Switch and Match
Switch:
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
- |
Renders its content if the condition in |
Match:
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Required |
- |
Item display condition. |
<Switch fallback={"Noname"}>
<Match when={context.name === "John"}>
John
</Match>
<Match when={context.name === "Alex"}>
Alex
</Match>
</Switch>
Piano Components
Piano provides a set of base components for Lightweight templates. You can use them as needed. These components will be expanded and improved in the future.
PianoPrimaryButton
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
- |
Optional CSS class name for the button element. |
|
|
|
Optional |
- |
Optional ID for the button element. |
|
|
|
Optional |
- |
Optional object for conditional CSS classes (e.g., |
|
|
|
Optional |
- |
Optional inline styles as a key-value object. |
|
|
|
Required |
- |
The content to be rendered inside the button. |
|
|
|
Required |
- |
Click event handler. Can be synchronous or asynchronous. |
|
|
|
Optional |
- |
Optional name attribute for the button (useful for forms). |
|
|
|
Optional |
- |
Whether the button is disabled. |
|
|
|
Optional |
- |
Optional CSS width value (e.g., |
|
|
|
Optional |
- |
Optional CSS height value. |
|
|
|
Optional |
- |
Optional CSS min-height value. |
|
|
|
Optional |
- |
Optional CSS min-width value. |
|
|
|
Optional |
- |
Optional CSS max-height value. |
|
|
|
Optional |
- |
Optional CSS max-width value. |
|
|
|
Optional |
- |
Optional icon element to display before the children. |
|
|
|
Optional |
- |
Optional icon element to display after the children. |
|
|
|
Optional |
- |
Optional name for an external event (e.g., for analytics tracking). |
|
|
|
Optional |
- |
Optional parameters to accompany the external event. |
|
|
|
Optional |
- |
Optional parameter provides button element. |
<PianoPrimaryButton
width="200px"
onClick={(e) => context.ding(item)}
externalEventName="my-external-event-name"
externalEventParams={{ param1: 'value', param2: 123 }}
>
My button
</PianoPrimaryButton>
With dynamic externalEventName, externalEventParams:
<PianoPrimaryButton
width="200px"
onClick={(e) => context.ding(item)}
externalEventName={context.myExternalEventName}
externalEventParams={context.myExternalEventParams}
>
My button
</PianoPrimaryButton>
PianoSecondaryButton
Supports the same properties as the PianoPrimaryButton.
<PianoSecondaryButton
width="200px"
onClick={(e) => context.ding(item)}
externalEventName={context.myExternalEventName}
externalEventParams={context.myExternalEventParams}
>
My secondary button
</PianoSecondaryButton>
PianoGhostButton
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
- |
Optional CSS class name for the button element. |
|
|
|
Optional |
- |
Optional ID for the button element. |
|
|
|
Optional |
- |
Optional object for conditional CSS classes (e.g., |
|
|
|
Optional |
- |
Optional inline styles as a key-value object. |
|
|
|
Required |
- |
The content to be rendered inside the button. |
|
|
|
Required |
- |
Click event handler. Can be synchronous or asynchronous. |
|
|
|
Optional |
- |
Optional name attribute for the button (useful for forms). |
|
|
|
Optional |
- |
Whether the button is disabled. |
|
|
|
Optional |
- |
Optional CSS width value (e.g., |
|
|
|
Optional |
- |
Optional CSS height value. |
|
|
|
Optional |
- |
Optional CSS min-height value. |
|
|
|
Optional |
- |
Optional CSS min-width value. |
|
|
|
Optional |
- |
Optional CSS max-height value. |
|
|
|
Optional |
- |
Optional CSS max-width value. |
|
|
|
Optional |
- |
Optional name for an external event (e.g., for analytics tracking). |
|
|
|
Optional |
- |
Optional parameters to accompany the external event. |
|
|
|
Optional |
- |
Optional parameter provides button element. |
<PianoGhostButton
width="200px"
onClick={(e) => context.ding(item)}
externalEventName="my-external-event-name"
externalEventParams={{ param1: 'value', param2: 123 }}
>
My ghost button
</PianoGhostButton>
PianoIconButton
Supports the same properties as the PianoGhostButton.
<PianoIconButton onClick={(e) => handleClick(e)}>
<svg>...</svg>
</PianoIconButton>
PianoCloseButton
Closes the widget on click and fires the onClose handler.
Supports the same properties as the PianoGhostButton.
<PianoCloseButton name="my button" onClose={(e) => console.log("closed")} />
You can pass your icon to change the default close icon:
<PianoCloseButton onClick={(e) => handleClick(e)}>
<svg>...</svg>
</PianoCloseButton>
See this article for an explanation of how the "Allow user to close modal" checkbox works for Lightweight templates.
PianoStartCheckoutButton
A wrapper component that triggers the classic checkout flow when clicked. Renders one of the supported button components based on the as prop. Supports all props of the rendered button.
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
|
Button variant to render. |
|
|
|
Required |
- |
Term for checkout. |
|
|
|
Required |
- |
The content to be rendered inside the button. |
|
|
|
Optional |
- |
Optional callback fired after checkout is triggered. |
|
|
|
Optional |
- |
Optional parameter provides button element. |
|
|
|
Optional |
- |
Optional CSS class name for the button element. |
|
|
|
Optional |
- |
Optional ID for the button element. |
|
|
|
Optional |
- |
Optional object for conditional CSS classes (e.g., |
|
|
|
Optional |
- |
Optional inline styles as a key-value object. |
|
|
|
Optional |
- |
Optional name attribute for the button (useful for forms). |
|
|
|
Optional |
- |
Whether the button is disabled. |
|
|
|
Optional |
- |
Optional CSS width value (e.g., |
|
|
|
Optional |
- |
Optional CSS height value. |
|
|
|
Optional |
- |
Optional CSS min-height value. |
|
|
|
Optional |
- |
Optional CSS min-width value. |
|
|
|
Optional |
- |
Optional CSS max-height value. |
|
|
|
Optional |
- |
Optional CSS max-width value. |
|
|
|
Optional |
- |
Optional name for an external event (e.g., for analytics tracking). |
|
|
|
Optional |
|
Optional parameters to accompany the external event. |
|
|
|
Optional |
- |
Accessible label for screen readers. |
<PianoStartCheckoutButton
term={term}
class="pn-offer__subscribe-button"
externalEventName="offer-subscribe"
>
<T>Subscribe</T>
</PianoStartCheckoutButton>
With a different button variant:
<PianoStartCheckoutButton
as="PianoSecondaryButton"
term={item}
externalEventName="offer-subscribe"
>
<T>Subscribe</T>
</PianoStartCheckoutButton>
PianoBuyAsAGiftButton
A wrapper component that triggers the classic checkout flow as a gift when clicked. Renders one of the supported button components based on the as prop. Supports all props of the rendered button.
|
Attribute name |
Type |
Required/Optional |
Default value |
Description |
|
|
|
optional |
|
Button variant to render. |
|
|
|
required |
— |
Term for checkout. |
|
|
|
required |
— |
The content to be rendered inside the button. |
|
|
|
optional |
— |
Optional callback fired after checkout is triggered. |
|
|
|
optional |
— |
Optional parameter provides button element. |
|
|
|
optional |
— |
Optional CSS class name for the button element. |
|
|
|
optional |
— |
Optional ID for the button element. |
|
|
|
optional |
— |
Optional object for conditional CSS classes (e.g., |
|
|
|
optional |
— |
Optional inline styles as a key-value object. |
|
|
|
optional |
— |
Optional name attribute for the button (useful for forms). |
|
|
|
optional |
— |
Whether the button is disabled. |
|
|
|
optional |
— |
Optional CSS width value (e.g., |
|
|
|
optional |
— |
Optional CSS height value. |
|
|
|
optional |
— |
Optional CSS min-height value. |
|
|
|
optional |
— |
Optional CSS min-width value. |
|
|
|
optional |
— |
Optional CSS max-height value. |
|
|
|
optional |
— |
Optional CSS max-width value. |
|
|
|
optional |
— |
Optional name for an external event (e.g., for analytics tracking). |
|
|
|
optional |
|
Optional parameters to accompany the external event. |
|
|
|
optional |
— |
Accessible label for screen readers. |
Example
<PianoBuyAsAGiftButton
term={term}
externalEventName="offer-gift"
>
<T>Buy as a gift</T>
</PianoBuyAsAGiftButton>
Forms
PianoInput
Default view:
Inline view:
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Required |
— |
The |
|
|
|
Optional |
|
Callback function triggered when the input value changes. |
|
|
|
Optional |
|
The type of the input (e.g., |
|
|
|
Optional |
|
Placeholder text displayed when the input is empty. |
|
|
|
Optional |
|
Indicates whether the input is in an invalid state. |
|
|
|
Optional |
|
Marks the input as required for form validation. |
|
|
|
Optional |
|
Disables the input, making it non‑interactive. |
|
|
|
Optional |
|
Makes the input read‑only, preventing changes. |
|
|
|
Optional |
|
The current value of the input. |
|
|
|
Optional |
|
Automatically focuses the input when the page loads. |
|
|
|
Optional |
|
Minimum number of characters allowed. |
|
|
|
Optional |
|
Maximum number of characters allowed. |
|
|
|
Optional |
|
Maximum value (for number inputs). |
|
|
|
Optional |
|
Minimum value (for number inputs). |
|
|
|
Optional |
|
Autocomplete hint for the browser (e.g., |
|
|
|
Optional |
|
Custom CSS height value. |
|
|
|
Optional |
|
Text alignment inside the input (e.g., |
|
|
|
Optional |
|
Callback function triggered when the Enter key is pressed while the input is focused. |
|
|
|
Optional |
|
Reference to the underlying HTML input element. |
|
|
|
Optional |
|
Custom CSS width value. |
|
|
|
Optional |
|
Custom CSS padding value. |
|
|
|
Optional |
|
Hint to the browser about the type of virtual keyboard to display. |
|
|
|
Optional |
|
Regular expression pattern for input validation. |
|
|
|
Optional |
|
CSS class name(s) to apply to the input. |
|
|
|
Optional |
|
Object mapping class names to boolean flags for conditional styling. |
|
|
|
Optional |
|
The unique identifier for the input element. |
|
|
|
Optional |
|
Inline styles as a key‑value object. |
|
|
|
Optional |
|
Text label associated with the input. |
|
|
|
Optional |
|
Icon element displayed on the left side of the input. |
|
|
|
Optional |
|
Icon element displayed on the right side of the input. |
|
|
|
Optional |
|
View mode. |
|
|
|
Optional |
|
Error message to display when the input is invalid. |
PianoCheckbox
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
|
CSS class name(s) to apply to the component. |
|
|
|
Optional |
|
Unique identifier for the element. |
|
|
|
Optional |
|
Object mapping class names to boolean flags for conditional styling. |
|
|
|
Optional |
|
Inline styles as a key‑value object. |
|
|
|
Required |
— |
The |
|
|
|
Optional |
|
Text label associated with the input. |
|
|
|
Optional |
|
Indicates whether the input is in an invalid state. |
|
|
|
Optional |
|
Marks the input as required for form validation. |
|
|
|
Optional |
|
Disables the input, making it non‑interactive. |
|
|
|
Optional |
|
Makes the input read‑only, preventing changes. |
|
|
|
Optional |
|
Indicates whether a checkbox or radio input is checked. |
|
|
|
Optional |
|
Callback function triggered when the input value changes. |
|
|
|
Optional |
|
Maximum width of the input (CSS |
|
|
|
Optional |
|
Error message to display when the input is invalid. |
|
|
|
Optional |
|
ARIA label for accessibility. |
PianoTextarea
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
|
CSS class name(s) to apply to the textarea. |
|
|
|
Optional |
|
Unique identifier for the textarea element. |
|
|
|
Optional |
|
Object mapping class names to boolean flags for conditional styling. |
|
|
|
Optional |
|
Inline styles as a key‑value object. |
|
|
|
Optional |
|
Text label associated with the textarea. |
|
|
|
Optional |
|
Error message to display when the textarea is invalid. |
|
|
|
Required |
— |
The |
|
|
|
Optional |
|
Indicates whether the textarea is in an invalid state. |
|
|
|
Optional |
|
Marks the textarea as required for form validation. |
|
|
|
Optional |
|
Disables the textarea, making it non‑interactive. |
|
|
|
Optional |
|
Makes the textarea read‑only, preventing changes. |
|
|
|
Optional |
|
The current value of the textarea. |
|
|
|
Optional |
|
Callback function triggered when the textarea value changes. |
|
|
|
Required |
— |
Placeholder text displayed when the textarea is empty. |
|
|
|
Optional |
|
Automatically focuses the textarea when the page loads. |
|
|
|
Optional |
|
Minimum number of characters allowed. |
|
|
|
Optional |
|
Maximum number of characters allowed. |
|
|
|
Optional |
|
Number of visible text lines (height in rows). |
|
|
|
Optional |
|
Average character width (width in columns). |
|
|
|
Optional |
|
Maximum width of the textarea (CSS |
|
|
|
Optional |
|
Custom CSS height value. |
|
|
|
Optional |
|
Custom CSS width value. |
|
|
|
Optional |
|
Reference to the underlying HTML textarea element. |
|
|
|
Optional |
|
CSS |
PianoRadioButton
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
|
CSS class name(s) to apply to the component. |
|
|
|
Optional |
|
Unique identifier for the input element. |
|
|
|
Optional |
|
Object mapping class names to boolean flags for conditional styling. |
|
|
|
Optional |
|
Inline styles as a key‑value object. |
|
|
|
Required |
— |
The |
|
|
|
Required |
— |
The value associated with this radio option (submitted when the radio is selected). |
|
|
|
Optional |
|
The currently selected value in the radio group. Used to determine if this radio is checked by comparing with |
|
|
|
Optional |
|
Text label displayed next to the radio button. |
|
|
|
Optional |
|
Indicates whether the radio is in an invalid state. |
|
|
|
Optional |
|
Marks the radio group as required (at least one option must be selected). |
|
|
|
Optional |
|
Disables the radio button, making it non‑interactive. |
|
|
|
Optional |
|
Makes the radio read‑only (selection cannot be changed). |
|
|
|
Optional |
|
Explicitly sets the checked state of the radio button. |
|
|
|
Optional |
|
Callback function triggered when the radio selection changes. |
PianoSelect
Default view:
Inline view:
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
|
CSS class name(s) to apply to the select component. |
|
|
|
Optional |
|
Unique identifier for the select element. |
|
|
|
Optional |
|
Object mapping class names to boolean flags for conditional styling. |
|
|
|
Optional |
|
Inline styles as a key‑value object. |
|
|
|
Required |
— |
The |
|
|
|
Optional |
|
Text label associated with the select. |
|
|
|
Optional |
|
Indicates whether the select is in an invalid state. |
|
|
|
Optional |
|
Marks the select as required for form validation. |
|
|
|
Optional |
|
Disables the select, making it non‑interactive. |
|
|
|
Optional |
|
Makes the select read‑only (selection cannot be changed). |
|
|
|
Optional |
|
Callback function triggered when the select value changes. |
|
|
|
Required |
— |
Array of options to display in the dropdown. Each option has |
|
|
|
Optional |
|
The |
|
|
|
Optional |
|
Maximum number of visible rows in the dropdown before scrolling. |
|
|
|
Required |
— |
Placeholder text displayed when no option is selected. |
|
|
|
Optional |
|
Maximum width of the select component (CSS |
|
|
|
Optional |
|
Visual variant of the select. |
|
|
|
Optional |
|
Icon element displayed on the left side of the select. |
|
|
|
Optional |
|
Error message to display when the select is invalid. |
Typography
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
- |
Optional CSS class name for the element. |
|
|
|
Optional |
- |
Optional ID for the element. |
|
|
|
Optional |
- |
Optional object for conditional CSS classes. |
|
|
|
Optional |
- |
Optional inline styles as a key-value object. |
|
|
|
Required |
- |
The content to be rendered inside the typography component. |
PianoHeadline
<PianoHeadline>Lorem ipsum dolor sit amet</PianoHeadline>
PianoSubHeadline
<PianoSubHeadline>Lorem ipsum dolor sit amet</PianoSubHeadline>
PianoText
<PianoText>Lorem ipsum dolor sit amet</PianoText>
PianoAccentedText
<PianoAccentedText>Lorem ipsum dolor sit amet</PianoAccentedText>
Complex
PianoHeader
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
|
Hide user control. |
|
|
|
Optional |
|
Hide locale selector. |
|
|
|
Optional |
|
Hide close button. |
<PianoHeader pianoIsCloseButtonHidden={true}></PianoHeader>
Fires an external event closeWidget on close button click.
Utility
PianoImg
Renders an image and displays a placeholder during loading.
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
- |
Optional CSS class name for the element. |
|
|
|
Optional |
- |
Optional ID for the element. |
|
|
|
Optional |
- |
Optional object for conditional CSS classes. |
|
|
|
Optional |
- |
Optional inline styles as a key-value object. |
|
|
|
Optional |
- |
Source URL of the image. |
|
|
|
Optional |
|
Width of the image (can be a string with units or a number). |
|
|
|
Optional |
|
Height of the image (can be a string with units or a number). |
|
|
|
Optional |
- |
Alternative text for the image (accessibility). |
<PianoImg src="image-src" width="64" height="64" alt="alt-text"></PianoImg>
PianoUserName
Renders Piano user name, full name or email.
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
- |
Optional CSS class name for the element. |
|
|
|
Optional |
- |
Optional ID for the element. |
|
|
|
Optional |
- |
Optional object for conditional CSS classes. |
|
|
|
Optional |
- |
Optional inline styles as a key-value object. |
|
|
|
Optional |
- |
Optional content to be rendered inside the component. |
|
|
|
Required |
- |
How the username will be presented. |
|
|
|
Optional |
- |
Rendered if the user does not exist. |
<PianoUserName
display="name | fullName | email"
fallback="Lorem ipsum"
class="username"
>
My external name(optional)
</PianoUserName>
PianoExternalEvent
Fire external event and sends auto micro conversion on click / submit.
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Required |
- |
External event name. |
|
|
|
Optional |
|
External event options. |
<PianoExternalEvent name="some-event" params={{ myParam:'my-param-value' }}>
<button>Test event</button>
</PianoExternalEvent>
To know more how to set up click tracking and reporting of multiple clickable elements e.g. buttons follow this FAQ.
A
Adds _ptid to the href and sends an auto micro conversion when the link is clicked.
Important: Do not change to . Our conversion-tracking implementation relies on the uppercase tag and will not track conversions otherwise.
Lowercase a is the standard HTML element without tracking, while uppercase A is our component with tracking.
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
- |
CSS class name for the element. |
|
|
|
Optional |
- |
Unique identifier for the element. |
|
|
|
Optional |
- |
Optional object for conditional CSS classes. |
|
|
|
Optional |
- |
Optional inline styles as a key-value object. |
|
|
|
Required |
- |
Child elements to render inside the component. |
|
|
|
Optional |
- |
If true, prevents link tracking. |
|
|
|
Optional |
- |
The URL to navigate to when the link is clicked. |
|
|
|
Optional |
- |
Specifies where to open the linked document (e.g., |
|
Other tag attributes |
- |
Optional |
- |
Standard HTML anchor attributes: |
<A href="my-external-link">
link text
</A>
PianoLocaleSelector
Renders the locale selector.
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
- |
CSS class name for the element. |
|
|
|
Optional |
- |
Unique identifier for the element. |
|
|
|
Optional |
- |
Optional object for conditional CSS classes. |
|
|
|
Optional |
- |
Optional inline styles as a key-value object. |
<PianoLocaleSelector></PianoLocaleSelector>
PianoUserControl
Renders a user control menu.
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
- |
CSS class name for the element. |
|
|
|
Optional |
- |
Unique identifier for the element. |
|
|
|
Optional |
- |
Optional object for conditional CSS classes. |
|
|
|
Optional |
- |
Optional inline styles as a key-value object. |
<PianoUserControl></PianoUserControl>
T (Translate)
Translates the passed string. See the Localization section for more details.
|
Attribute Name |
Type |
Required/Optional |
Default Value |
Description |
|---|---|---|---|---|
|
|
|
Optional |
- |
The context from which translations will be taken. |
|
|
|
Optional |
- |
Inserts variables into the translated string. |
<T>string to translate</T>
<T context="offer.component">string to translate</T>
<T
template={{ templateVariable: item, otherTemplateVariable: userName }}
>
string to translate [[templateVariable]] with template [[otherTemplateVariable]]
</T>