Using Lightning Base Components
Lightning Base Components (LBC) are the lightning-* web components shipped
by Salesforce. This skill routes an agent through the right decision sequence
so the final component choice is as specific as possible and backed by
real API docs — not a hand-rolled reimplementation of something that already
exists.
When to Use This Skill
- User describes a UI need ("searchable dropdown", "record edit form",
"modal with footer") and asks which
lightning-* component fits.
- User is about to build a primitive (button group, combobox, toast) and
should be using LBC instead.
- User asks you to review LWC markup for LBC-related issues — specifically
overriding SLDS classes or restyling LBC internals.
- User needs the authoritative props/events/slots for a specific
lightning-* tag.
Prerequisites
- Knowledge of which LBC namespace your org uses (
lightning is the default
public namespace; some platforms expose lightning-community or others —
the user's meta files will clarify).
- The skill ships authoritative API docs for every Lightning Base Component
in references/lightning-components.md.
Each component is a
# Component API Structure block; grep for
**Name:** <camelCaseName> (e.g. **Name:** datatable) to jump to its
Properties / Methods / Events / Slots. Read this rather than relying on
cached knowledge — LBC evolves and the reference is the source of truth.
Workflow
Step 1 — Read the entire component index first
Open lightning-component-index.md
and scan all entries before making any selection. This is non-negotiable:
LBC's value comes from picking the most specialized component, and skipping
the scan leads to reinventing compound widgets out of primitives.
As you scan, compile a candidate list — every component whose description
touches any aspect of the use case. Do not filter or rank yet.
Step 2 — Narrow to the most specific fit per feature
Once the scan is complete:
- For each feature in the use case, select the most specific component
that covers it. Prefer a specialized compound (
lightning-record-form,
lightning-tabset, lightning-datatable) over a generic primitive
(lightning-input, lightning-button) when the specialized one covers
the scenario end-to-end.
- Avoid duplication: if
lightning-record-form already renders fields for a
record, do not pair it with lightning-input-field unless you're
explicitly overriding behavior.
Step 3 — Share the shortlist and confirm
Present the final shortlist to the developer with a one-line rationale per
component. Wait for explicit confirmation before pulling full API docs. This
prevents the agent from burning context on components the developer has
already mentally ruled out.
Step 4 — Retrieve full API docs
Once confirmed, use the bundled helper to pull the exact API blocks — this
avoids ad-hoc grepping across a large reference:
scripts/extract-component-docs.sh <camelCaseName> [<camelCaseName>...]
Convert lightning-<foo> tags to camelCase (no lightning- prefix):
lightning-datatable → datatable
lightning-record-edit-form → recordEditForm
lightning-button-icon → buttonIcon
Each returned block has the same shape: Basic Information (tag, namespace,
type), Properties (name, type, default, description), Methods,
Events, Slots, and (where applicable) usage notes. This skill is about
picking the components; the bundled reference is about wiring them.
Step 5 — Produce integration guidance
Using the per-component reference, walk the developer through:
- The exact
<lightning-...> tag and required attributes.
- Which events to bind (
onchange, oncommit, onsuccess, …) and what
the event payload contains.
- Any slots to fill (headers, footers, custom content).
- Known constraints from the component docs (e.g.
lightning-record-form
requires object-api-name and record-id for edit/view modes).
Step 6 — Respect LBC styling rules
Do not override SLDS classes on LBC internals. See
lbc-expert-guidance.md for specifics.
Common issues:
- Targeting
.slds-button or .slds-input in the host component's CSS to
restyle an LBC — LBC ships inside a shadow root, so these selectors
either leak into sibling components or get stripped entirely. Use the
component's documented styling hooks (--sds-c-button-*, etc.) instead.
- Wrapping an LBC just to mutate its internal markup. You can't — the
markup is hidden behind the shadow root. If the component doesn't expose
the slot/prop you need, that's a platform-level gap, not a restyling job.
Examples
Example — "I need a multi-select combobox with typeahead"
- Scan the component index end-to-end.
- Candidate list includes:
lightning-combobox, lightning-dual-listbox,
lightning-record-picker.
- Shortlist:
lightning-dual-listbox (the documented multi-select base
component). Rule out lightning-combobox — its documented API is
single-select; it has no type="multi" and no multi-select mode.
Flag that lightning-record-picker only fits if the values are record IDs.
- Developer confirms
lightning-dual-listbox.
- Run
scripts/extract-component-docs.sh dualListbox.
- Return the
options, value, onchange payload, and required label
props from the block's Properties / Events sections.
Example — "I'm going to write my own modal"
- Scan finds
lightning-modal, lightning-modal-body,
lightning-modal-footer, lightning-modal-header.
- Shortlist is the 4 modal components.
- Confirm.
- Run
scripts/extract-component-docs.sh modal modalHeader modalBody modalFooter
→ full modal API (how to extend LightningModal, the static .open()
pattern, slotting the header/body/footer).
- Steer the developer away from rolling their own dialog.
Verification Checklist
Troubleshooting
- Grep for
**Name:** <name> returns no match — name is wrong, or the
reference uses a different camelCase. Double-check against the component
index (lightning-record-form → recordForm,
lightning-record-view-form → recordViewForm,
lightning-button-icon → buttonIcon).
- Proposed component doesn't have the prop you expected — trust the
real API doc over memory. LBC evolves; cached knowledge lies.
- Developer resists the shortlist — don't skip Step 4. Still retrieve
the docs for the developer's preferred choice so they see the actual
trade-offs.
- Developer wants to restyle LBC internals — redirect to styling hooks
(see the LBC Expert reference). Refusing shadow DOM penetration is the
correct answer.
1---2name: experience-lwc-base-components-integrate3description: Pick the right Lightning Base Component (`lightning-*`) for a given UI task, retrieve its full API (props, methods, events, slots) from the bundled per-component reference, and wire it into an LWC (LWC `.html`, `.js`, and `.css` files) without breaking SLDS. Use this skill when users say "I need a Lightning modal / datatable / combobox / record form", ask which `lightning-*` component fits a use case, want a shortlist of LBC candidates, are about to hand-roll a UI that a base component already provides, or are editing an LWC bundle's `.html` / `.js` / `.css` and need to select or wire a base component. Also triggers on "Lightning base component", "LBC", "lightning-combobox", "lightning-datatable", "use `lightning-` tag". DO NOT TRIGGER for applying SLDS design tokens, blueprints, or styling guidance in general — that is `design-systems-slds-apply`; this skill only selects and wires `lightning-*` base components.4---5<!-- adk-managed-skill -->
6
7# Using Lightning Base Components
8
9Lightning Base Components (LBC) are the `lightning-*` web components shipped
10by Salesforce. This skill routes an agent through the right decision sequence
11so the final component choice is **as specific as possible** and backed by
12real API docs — not a hand-rolled reimplementation of something that already
13exists.
14
15## When to Use This Skill
16
17- User describes a UI need ("searchable dropdown", "record edit form",
18 "modal with footer") and asks which `lightning-*` component fits.
19- User is about to build a primitive (button group, combobox, toast) and
20 should be using LBC instead.
21- User asks you to review LWC markup for LBC-related issues — specifically
22 overriding SLDS classes or restyling LBC internals.
23- User needs the authoritative props/events/slots for a specific
24 `lightning-*` tag.
25
26## Prerequisites
27
28- Knowledge of which LBC namespace your org uses (`lightning` is the default
29 public namespace; some platforms expose `lightning-community` or others —
30 the user's meta files will clarify).
31- The skill ships authoritative API docs for every Lightning Base Component
32 in [references/lightning-components.md](references/lightning-components.md).
33 Each component is a `# Component API Structure` block; grep for
34 `**Name:** <camelCaseName>` (e.g. `**Name:** datatable`) to jump to its
35 Properties / Methods / Events / Slots. Read this rather than relying on
36 cached knowledge — LBC evolves and the reference is the source of truth.
37
38
39## Workflow
40
41### Step 1 — Read the **entire** component index first
42
43Open [lightning-component-index.md](references/lightning-component-index.md)
44and scan **all** entries before making any selection. This is non-negotiable:
45LBC's value comes from picking the most specialized component, and skipping
46the scan leads to reinventing compound widgets out of primitives.
47
48As you scan, compile a **candidate list** — every component whose description
49touches any aspect of the use case. Do not filter or rank yet.
50
51### Step 2 — Narrow to the most specific fit per feature
52
53Once the scan is complete:
54
55- For each feature in the use case, select the **most specific** component
56 that covers it. Prefer a specialized compound (`lightning-record-form`,
57 `lightning-tabset`, `lightning-datatable`) over a generic primitive
58 (`lightning-input`, `lightning-button`) when the specialized one covers
59 the scenario end-to-end.
60- Avoid duplication: if `lightning-record-form` already renders fields for a
61 record, do not pair it with `lightning-input-field` unless you're
62 explicitly overriding behavior.
63
64### Step 3 — Share the shortlist and confirm
65
66Present the final shortlist to the developer with a one-line rationale per
67component. Wait for explicit confirmation before pulling full API docs. This
68prevents the agent from burning context on components the developer has
69already mentally ruled out.
70
71### Step 4 — Retrieve full API docs
72
73Once confirmed, use the bundled helper to pull the exact API blocks — this
74avoids ad-hoc grepping across a large reference:
75
76```bash
77scripts/extract-component-docs.sh <camelCaseName> [<camelCaseName>...]
78```
79
80Convert `lightning-<foo>` tags to camelCase (no `lightning-` prefix):
81
82- `lightning-datatable` → `datatable`
83- `lightning-record-edit-form` → `recordEditForm`
84- `lightning-button-icon` → `buttonIcon`
85
86Each returned block has the same shape: **Basic Information** (tag, namespace,
87type), **Properties** (name, type, default, description), **Methods**,
88**Events**, **Slots**, and (where applicable) usage notes. This skill is about
89**picking** the components; the bundled reference is about **wiring** them.
90
91### Step 5 — Produce integration guidance
92
93Using the per-component reference, walk the developer through:
94
95- The exact `<lightning-...>` tag and required attributes.
96- Which events to bind (`onchange`, `oncommit`, `onsuccess`, …) and what
97 the event payload contains.
98- Any slots to fill (headers, footers, custom content).
99- Known constraints from the component docs (e.g. `lightning-record-form`
100 requires `object-api-name` and `record-id` for edit/view modes).
101
102### Step 6 — Respect LBC styling rules
103
104Do not override SLDS classes on LBC internals. See
105[lbc-expert-guidance.md](references/lbc-expert-guidance.md) for specifics.
106Common issues:
107
108- Targeting `.slds-button` or `.slds-input` in the host component's CSS to
109 restyle an LBC — LBC ships inside a shadow root, so these selectors
110 either leak into sibling components or get stripped entirely. Use the
111 component's documented styling hooks (`--sds-c-button-*`, etc.) instead.
112- Wrapping an LBC just to mutate its internal markup. You can't — the
113 markup is hidden behind the shadow root. If the component doesn't expose
114 the slot/prop you need, that's a platform-level gap, not a restyling job.
115
116
117## Examples
118
119### Example — "I need a multi-select combobox with typeahead"
120
1211. Scan the component index end-to-end.
1222. Candidate list includes: `lightning-combobox`, `lightning-dual-listbox`,
123 `lightning-record-picker`.
1243. Shortlist: `lightning-dual-listbox` (the documented multi-select base
125 component). Rule out `lightning-combobox` — its documented API is
126 single-select; it has no `type="multi"` and no multi-select mode.
127 Flag that `lightning-record-picker` only fits if the values are record IDs.
1284. Developer confirms `lightning-dual-listbox`.
1295. Run `scripts/extract-component-docs.sh dualListbox`.
1306. Return the `options`, `value`, `onchange` payload, and required label
131 props from the block's Properties / Events sections.
132
133### Example — "I'm going to write my own modal"
134
1351. Scan finds `lightning-modal`, `lightning-modal-body`,
136 `lightning-modal-footer`, `lightning-modal-header`.
1372. Shortlist is the 4 modal components.
1383. Confirm.
1394. Run `scripts/extract-component-docs.sh modal modalHeader modalBody modalFooter`
140 → full modal API (how to extend `LightningModal`, the static `.open()`
141 pattern, slotting the header/body/footer).
1425. Steer the developer away from rolling their own dialog.
143
144
145## Verification Checklist
146
147- [ ] The full component index was scanned before any selection (no
148 keyword-search shortcutting).
149- [ ] Candidate list included every component that touches the use case.
150- [ ] Final shortlist selects the **most specific** component per feature.
151- [ ] Developer confirmed the shortlist before the bundled component
152 reference was opened.
153- [ ] Integration guidance cites props / events / slots from the real API
154 docs (not inferred).
155- [ ] No suggestions to restyle LBC by overriding SLDS classes.
156
157
158## Troubleshooting
159
160- **Grep for `**Name:** <name>` returns no match** — name is wrong, or the
161 reference uses a different camelCase. Double-check against the component
162 index (`lightning-record-form` → `recordForm`,
163 `lightning-record-view-form` → `recordViewForm`,
164 `lightning-button-icon` → `buttonIcon`).
165- **Proposed component doesn't have the prop you expected** — trust the
166 real API doc over memory. LBC evolves; cached knowledge lies.
167- **Developer resists the shortlist** — don't skip Step 4. Still retrieve
168 the docs for the developer's preferred choice so they see the actual
169 trade-offs.
170- **Developer wants to restyle LBC internals** — redirect to styling hooks
171 (see the LBC Expert reference). Refusing shadow DOM penetration is the
172 correct answer.