---
title: "asChild without exactly one element child (shadcn/as-child-single-element)"
description: "Slot clones a single child; text, fragments or several children throw React.Children.only."
url: http://localhost:4173/rules/shadcn/as-child-single-element
updated: 2026-11-11
---

# asChild without exactly one element child

> `shadcn/as-child-single-element` is a vetd rule. It flags: asChild without exactly one element child. It runs on every `check`, together with the TypeScript check.

| Fact | Value |
| --- | --- |
| Rule id | `shadcn/as-child-single-element` |
| Severity | error |
| Group | shadcn/ui and Radix composition |
| Tags | react, correctness |

## Why it matters

Slot clones a single child; text, fragments or several children throw React.Children.only.

## How to fix it

Wrap the children in one element.

## Credit

Based on work by:

- [Radix UI](https://www.radix-ui.com): asChild requires exactly one child element that receives the merged props.

## References

- [Composition – Radix Primitives](https://www.radix-ui.com/primitives/docs/guides/composition), Radix UI

## Related rules

- [`shadcn/nested-trigger`](http://localhost:4173/rules/shadcn/nested-trigger.md)
- [`shadcn/base-ui-as-child`](http://localhost:4173/rules/shadcn/base-ui-as-child.md)

## Get this text from vetd

MCP: call `explain` with `{ "diagnosticId": "shadcn/as-child-single-element" }`. CLI: `npx vetd explain shadcn/as-child-single-element`.

---

[All 92 rules](http://localhost:4173/rules.md) · Previous: [`shadcn/nested-trigger`](http://localhost:4173/rules/shadcn/nested-trigger.md) · Next: [`shadcn/dialog-title`](http://localhost:4173/rules/shadcn/dialog-title.md)
