Skip to content

LG-3328: SegmentedController component now accepts React.ReactNode instead of string for Label prop #1824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/little-spoons-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/segmented-control': minor
---

Label prop now accepts type `React.ReactNode` instead of `string`
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const SegmentedControl = forwardRef<

const name = useIdAllocator({
prefix: 'segmented-control',
id: nameProp ?? label,
id: nameProp,
});

// If a value is given, then it's controlled
Expand Down Expand Up @@ -374,7 +374,7 @@ SegmentedControl.propTypes = {
onChange: PropTypes.func,
defaultValue: PropTypes.string,
value: PropTypes.string,
label: PropTypes.string,
label: PropTypes.node,
name: PropTypes.string,
followFocus: PropTypes.bool,
className: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from 'react';

import { HTMLElementProps } from '@leafygreen-ui/lib';

export const DeprecatedSize = {
Expand Down Expand Up @@ -49,7 +51,7 @@ export interface SegmentedControlProps
/**
* A text label to the left of the segmented control. Sets the `name` prop if none is provided.
*/
label?: string;
label?: React.ReactNode;

/**
* Identifies the segmented control group to screen readers. Auto-generated if no `name` or `label` is provided.
Expand Down