Set up project
Install dependencies
Write tests
Required business details Required

Documentation

A checkbox list item with a text label. When clicked, toggles the checked state and fires onclick with the new boolean value. Supports a custom checkboxLabel snippet to replace the default text display. The checked state is bindable for two-way binding. Purpose-built for a single checkbox + label row — for a richer multi-section row (image, expandable detail, several independent click targets) with no selection semantics, use ListItem instead.

Usage

<script>
  import { CheckListItem } from '@juspay/svelte-ui-components';
</script>

<CheckListItem text={'...'} />

Props

Prop Type Required Default Description
text string Yes - The label text for the checkbox item.
checked boolean No false Bindable. The current checked state of the checkbox.
disabled boolean No false When true, the checkbox control is non-interactive and visually dimmed while label content remains fully opaque.
testId string No undefined Value for the data-pw attribute used in Playwright test selectors.
classes string No - CSS class string applied to the component's top-level element. Useful for theming — define classes with CSS variable overrides and pass them to create variant styles.

Snippets

Svelte 5 Snippet props — pass content blocks to the component.

Snippet Type Description
checkboxLabel Snippet A Svelte 5 Snippet that replaces the default text label with custom content.

Events

Event Type Description
onclick (checked: boolean) => void Fires after the checkbox state changes. Receives the new boolean checked value.

CSS Variables

Override these custom properties to theme the component.

Variable Default CSS Property Description
--check-list-item-display flex display Display mode of the checkbox item container.
--check-list-item-align-items center align-items Vertical alignment of checkbox and label.
--check-list-item-width 100% width Width of the checkbox item.
--check-list-item-padding - padding Inner padding of the checkbox item.
--check-list-item-gap 8px gap Gap between the checkbox and the label.
--check-list-item-disabled-opacity 0.4 opacity Opacity of the checkbox control when disabled.
--check-list-item-text-size 14px font-size Font size of the label text.
--check-list-item-text-color - color Color of the label text when unchecked.
--check-list-item-checked-text-color - color Color of the label text when checked.
--check-list-item-checked-font-weight - font-weight Font weight of the label text when checked.

Accessibility

The checkbox is named by the label the row shows, so what a screen reader announces and what a speech-input user can see are the same words: text by default, or everything a checkboxLabel snippet renders (a label of Required business details <strong>Required</strong> is announced as "Required business details Required", not just text). The checkbox references that label with aria-labelledby; text is kept as aria-label, used only if the label renders nothing.

Each item exposes exactly one selection control. The native <input type="checkbox"> behind it is a form mirror: aria-hidden, tabindex="-1" and not reachable by pointer. A disabled item stays named and reports aria-disabled="true", drops out of the Tab order and ignores pointer and keyboard activation. Space and Enter toggle the focused box. CheckListItem has no name/value, so it contributes no field to a surrounding <form> and does not submit it — use Checkbox for that.

The wrapper element that carries the label's id is display: contents, so it adds no box: the text or snippet remains a direct flex item of the row and every --check-list-item-* variable behaves as before.

Internal Dependencies

This component uses the following library components internally:

  • Checkbox (for the checkbox control)

Web Component

Tag: <sui-check-list-item>

<sui-check-list-item text="Task 1" checked>
  <span slot="checkbox-label">Custom label</span>
</sui-check-list-item>

onclick is this element's only callback prop. It is a JS-property-only callback (item.onclick = (checked) => ...) and does not dispatch a DOM event: click is already HTMLElement's own native event, so an item.addEventListener('click', ...) listener already sees the real click that bubbles out of the shadow root on its own, and a synthetic one under the same name would double-deliver it to that same listener.

Slots

Slot Name Maps to Snippet Description
checkbox-label checkboxLabel Custom label content for the checkbox; defaults to the plain text string.