---
url: /reference/@cssdoc/core/functions/parseStructureVariants.md
---
# Function: parseStructureVariants()

```ts
function parseStructureVariants(
   raw, 
   parse?, 
   ownerRecordName?
): StructureVariant[] | undefined;
```

Defined in: [packages/core/src/grammar.ts:1069](https://github.com/thedannywahl/cssdoc/blob/main/packages/core/src/grammar.ts#L1069)

Split a `@structure` body into alternative [StructureVariant](../interfaces/StructureVariant.md)s when it has one or more
top-level `@variant <name>? { … }` blocks — an author saying "pick one of these DOM shapes" (e.g. a
`<label>` wrapping a control vs. a `<label for>` + a sibling control), as opposed to `parseStructure`'s
default of "these roots all coexist". A bare (non-`@variant`) run of top-level nodes becomes an
unnamed variant in place. This only handles the top level (the whole tree alternates); a `@variant`
nested deeper is a local choice at one child position, handled by buildStructureNodes instead
and stored on that node's [StructureNode.variants](../interfaces/StructureNode.md#variants).

## Parameters

### raw

`string`

### parse?

[`CssParse`](../type-aliases/CssParse.md)

### ownerRecordName?

`string`

## Returns

[`StructureVariant`](../interfaces/StructureVariant.md)\[] | `undefined`

`undefined` when the body has no top-level `@variant` block (the common case).
