Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,51 @@ import ShareSquareIcon from '@patternfly/react-icons/dist/esm/icons/share-square

## Examples

### Default with multiple selectable
```ts file="./ToggleGroupDefaultMultiple.tsx"
```
### Single select toggle group

A single select toggle group allows users to toggle between multiple items.

To support single selection, use the `onChange` callback to pass the selected `<ToggleGroupItem>` to `isSelected`.

### Default with single selectable
```ts file="./ToggleGroupDefaultSingle.tsx"
```

### Icons
### Multi select toggle group

A multi select toggle group allows users to select multiple items at once.

When a toggle item is disabled it cannot be selected. Click the "Disable all" button in the following example to see this in action.

To support multiple selection, use the `onChange` callback to pass each selected `<ToggleGroupItem>` to `isSelected`.

```ts file="./ToggleGroupDefaultMultiple.tsx"
```

### With icons

You can use a recognizable icon as a toggle item label.

To do this, pass an imported icon to the `icon` property of a `<ToggleGroupItem>`.

```ts file="./ToggleGroupIcon.tsx"
```

### Text and icons
### With text and icons

Adding text to a toggle item with an icon helps clarify the button's function.

To do this, pass a descriptive label to the `text` property of a `<ToggleGroupItem>`.

When passing both `text` and `icon` properties to a `<ToggleGroupItem>`, you can also pass in `iconPosition` to determine whether the icon is rendered at the start or end of the item.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the update that added this prop was in the v6 branch, this line should be removed for this PR, but we would want to add it to the v6 branch whenever this update gets pulled into v6 (or we could open a separate PR that adds this content to v6).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that makes sense. Do you think I can just link that additional PR to the same issue, or is a new issue needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've done either way, but a new issue wouldn't hurt. For what it's worth Michael had split out an issue assigned to me in Core into 2 separate issues, one for V5 and one for V6.


```ts file="./ToggleGroupTextIcon.tsx"
```

### Compact variant
### Compact toggle group

When space in a UI is limited, you can use a compact toggle group.

To apply compact styling to a `<ToggleGroup>`, use `isCompact`.

```ts file="./ToggleGroupCompact.tsx"
```
```