Skip to content

Commit e081b2f

Browse files
Merge pull request #4418 from Shopify/jhen__update_checkbox_docs_to_support_label_slot__2025-10
Update checkbox docs to support label slot (2025-10)
2 parents fa9df66 + a12d6b5 commit e081b2f

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

.changeset/checkbox-rich-label.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/ui-extensions': patch
3+
---
4+
5+
The `label` prop on the checkout and customer-account `s-checkbox` component now accepts a label as a slot in addition to a plain string, label slots can include only plain text and s-links.

packages/ui-extensions/src/surfaces/checkout/components/Checkbox.d.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,21 @@
1010
/// <reference lib="DOM" />
1111
import type {CheckboxProps$1} from './components-shared.d.ts';
1212

13-
/** @publicDocs */
13+
/**
14+
* The base properties for elements that don't have children, providing essential attributes like keys and refs for component management.
15+
*/
1416
export interface BaseElementProps<TClass = HTMLElement> {
17+
/**
18+
* A unique identifier for this element within its parent. This is used by the rendering engine for efficient reconciliation when lists change.
19+
*/
1520
key?: preact.Key;
21+
/**
22+
* A reference to the underlying DOM element, typically created using `useRef()`. This allows you to access and manipulate the DOM element directly in your component logic.
23+
*/
1624
ref?: preact.Ref<TClass>;
25+
/**
26+
* Assigns the element to a named slot in a parent component that uses slot-based composition patterns.
27+
*/
1728
slot?: Lowercase<string>;
1829
}
1930
/**
@@ -33,8 +44,14 @@ export type CallbackEventListener<TTagName extends keyof HTMLElementTagNameMap,
3344

3445
declare const tagName = "s-checkbox";
3546
/** @publicDocs */
36-
export interface CheckboxElementProps extends Pick<CheckboxProps$1, 'accessibilityLabel' | 'checked' | 'command' | 'commandFor' | 'defaultChecked' | 'disabled' | 'error' | 'id' | 'label' | 'name' | 'required' | 'value'> {
47+
export interface CheckboxElementProps extends Pick<CheckboxProps$1, 'accessibilityLabel' | 'checked' | 'command' | 'commandFor' | 'defaultChecked' | 'disabled' | 'error' | 'id' | 'name' | 'required' | 'value'> {
3748
command?: Extract<CheckboxProps$1['command'], '--auto' | '--show' | '--hide' | '--toggle'>;
49+
/**
50+
* The visual content to use as the control label. Use a string to provide a simple text label displayed to the user.
51+
*
52+
* If a `label` slot is also provided, the slot content takes precedence. [Learn more about slots](/docs/api/{API_NAME}/{API_VERSION}/web-components/forms/checkbox#slots-propertydetail-label).
53+
*/
54+
label?: string;
3855
}
3956
/** @publicDocs */
4057
export interface CheckboxEvents extends Pick<CheckboxProps$1, 'onChange'> {
@@ -53,6 +70,15 @@ export interface CheckboxElement extends CheckboxElementProps, Omit<HTMLElement,
5370
onchange: CheckboxEvents['onChange'];
5471
}
5572
/** @publicDocs */
73+
export interface CheckboxElementSlots {
74+
/**
75+
* The visual content to use as the control label.
76+
*
77+
* Use an `HTMLElement` as a rich control label composed of elements. Only an `s-text` element is supported with plain text and `s-link` as its only allowed children. Any other elements are stripped while preserving their text content.
78+
*/
79+
label?: HTMLElement;
80+
}
81+
/** @publicDocs */
5682
export interface CheckboxProps extends CheckboxElementProps, CheckboxEvents {
5783
}
5884
declare global {
@@ -68,4 +94,4 @@ declare module 'preact' {
6894
}
6995
}
7096

71-
export type { CheckboxElement, CheckboxElementEvents, CheckboxElementProps, CheckboxEvents, CheckboxProps };
97+
export type { CheckboxElement, CheckboxElementEvents, CheckboxElementProps, CheckboxElementSlots, CheckboxEvents, CheckboxProps };

0 commit comments

Comments
 (0)