Forms segment

From Legal-and-General/canopy · View interactive version

Forms segment is an AI agent skill from the GitHub repository Legal-and-General/canopy. Best practices for the Canopy Segment component. Trigger when adding conscious single-choice selectors, question-and-answer journey controls, or compact radio alternatives in a form in an Angular project using Canopy.

How to use this skill

Skill file

Canopy Segment — Best Practices

This skill provides usage guidance, dos and don'ts, and input reference for the Canopy segment control from @legal-and-general/canopy.

Apply this skill whenever you use LgSegmentGroupComponent or LgSegmentButtonComponent.

Segment buttons are implemented as restyled radio buttons. Import LgRadioComponent to use them.


Import

import { LgRadioGroupComponent, LgRadioButtonComponent } from '@legal-and-general/canopy';

Basic Usage

<lg-segment-group formControlName="colour">
  Colour
  <lg-hint>Select one option</lg-hint>
  <lg-segment-button value="red">Red</lg-segment-button>
  <lg-segment-button value="blue">Blue</lg-segment-button>
  <lg-segment-button value="green">Green</lg-segment-button>
</lg-segment-group>

Inputs

LgRadioGroupComponent (used for segment)

| Input | Type | Default | Description |

|-------|------|---------|-------------|

| id | string | auto-generated | HTML id attribute. |

| name | string | auto-generated | Sets name on all buttons in the group. |

| value | boolean \| string | null | Default selected value. |

| focus | boolean | null | Sets focus on the fieldset. |

| stack | 'md' \| 'lg' | false | Stacks buttons vertically at the given breakpoint. |

LgRadioButtonComponent (used for segment buttons)

| Input | Type | Default | Required | Description |

|-------|------|---------|----------|-------------|

| id | string | auto-generated | No | HTML id attribute. |

| name | string | null | Yes | HTML name attribute. |

| value | string | null | Yes | HTML value attribute. |

| ariaDescribedBy | string | null | No | ID of describing element. |


Dos and Don'ts

Do

  1. Do use when only one option can be selected from 2–5 choices and vertical space is limited.
  2. Do use the vertical (stack) variant on mobile when horizontal space is insufficient.
  3. Do keep labels short and concise to ensure they fit within the buttons without wrapping.

Don't

  1. Don't use when multiple items can be selected — use checkboxes instead.
  2. Don't use when there are more than 5 options — use the select component instead.
  3. Don't use for navigation — use tabs or a button group instead.

Accessibility


Design Constraints

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.