Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f93741b
Added icon change is animated.
aravind3566 Nov 7, 2024
c259d14
Update SegmentedButtons.tsx
aravind3566 Nov 7, 2024
8afc429
Update SegmentedButtonItem.tsx
aravind3566 Nov 7, 2024
34c3ca7
Update SegmentedButtonItem.tsx
aravind3566 Nov 7, 2024
0640694
Update SegmentedButtonItem.tsx
aravind3566 Nov 7, 2024
a671ed8
Update SegmentedButtonItem.tsx
aravind3566 Nov 7, 2024
1cd4012
Update SegmentedButtonItem.tsx
aravind3566 Nov 7, 2024
fac696d
Update SegmentedButtons.tsx
aravind3566 Nov 8, 2024
9b3ae85
Update SegmentedButtonItem.tsx
aravind3566 Nov 8, 2024
29b7793
Update Button.tsx
aravind3566 Nov 19, 2024
e57f88c
Update Button.tsx
aravind3566 Nov 19, 2024
a8242c0
Update Button.tsx
aravind3566 Nov 19, 2024
10e2c15
Merge pull request #1 from aravind3566/aravind3566-update-button-noOf…
aravind3566 Nov 19, 2024
a9b2530
Update Button.tsx
aravind3566 Nov 19, 2024
1c676aa
Update Button.tsx
aravind3566 Nov 19, 2024
c979ba5
Merge branch 'callstack:main' into main
aravind3566 Dec 5, 2024
c453243
Merge branch 'main' into aravind3566-update-button-noOfLines
aravind3566 Dec 5, 2024
c9d9020
Merge pull request #2 from aravind3566/aravind3566-update-button-noOf…
aravind3566 Dec 5, 2024
3eb0cb2
Merge branch 'main' into main
aravind3566 May 29, 2025
d52adda
Update Button.tsx
aravind3566 May 29, 2025
522f8c8
Merge branch 'callstack:main' into main
aravind3566 Jun 6, 2025
8e9f188
Merge branch 'callstack:main' into main
aravind3566 Jun 24, 2025
54d2ffb
Merge branch 'main' into main
aravind3566 May 21, 2026
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
20 changes: 19 additions & 1 deletion src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
* Sets additional distance outside of element in which a press can be detected.
*/
hitSlop?: TouchableRippleProps['hitSlop'];
/**
* Label text number Of Lines of the button.
*/
numberOfLines?: number;
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
/**
* Style for the button text.
Expand Down Expand Up @@ -185,6 +189,7 @@ const Button = (
onPressOut,
onLongPress,
delayLongPress,
numberOfLines,
style,
theme: themeOverrides,
uppercase: uppercaseProp,
Expand Down Expand Up @@ -269,6 +274,19 @@ const Button = (

const borderRadius = theme.shapes.corner.largeIncreased;
const iconSize = 18;
const NumberOfLines = numberOfLines ? numberOfLines : 1;

const { backgroundColor, borderColor, textColor, borderWidth } =
getButtonColors({
customButtonColor,
customTextColor,
theme,
mode,
disabled,
dark,
});
const borderRadius = theme.shapes.corner.largeIncreased;
const iconSize = 18;

const {
backgroundColor,
Expand Down Expand Up @@ -400,7 +418,7 @@ const Button = (
<Text
variant="labelLarge"
selectable={false}
numberOfLines={1}
numberOfLines={NumberOfLines}
testID={`${testID}-text`}
style={[
styles.label,
Expand Down
22 changes: 19 additions & 3 deletions src/components/SegmentedButtons/SegmentedButtonItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getSegmentedButtonDensityPadding,
} from './utils';
import { useInternalTheme } from '../../core/theming';
import CrossFadeIcon from '../CrossFadeIcon';
import type { ThemeProp } from '../../types';
import type { IconSource } from '../Icon';
import Icon from '../Icon';
Expand All @@ -33,6 +34,10 @@ export type Props = {
* Icon to display for the `SegmentedButtonItem`.
*/
icon?: IconSource;
/**
* Whether an icon change is animated.
*/
animated?: boolean;
/**
* @supported Available in v5.x with theme version 3
* Custom color for unchecked Text and Icon.
Expand Down Expand Up @@ -68,6 +73,10 @@ export type Props = {
* Label text of the button.
*/
label?: string;
/**
* Label text number of lines of the button.
*/
numberOfLines?: number;
/**
* Button segment.
*/
Expand Down Expand Up @@ -105,6 +114,7 @@ export type Props = {

const SegmentedButtonItem = ({
checked,
animated = false,
accessibilityLabel,
disabled,
style,
Expand All @@ -116,6 +126,7 @@ const SegmentedButtonItem = ({
icon,
testID,
label,
numberOfLines,
onPress,
segment,
density = 'regular',
Expand Down Expand Up @@ -192,7 +203,8 @@ const SegmentedButtonItem = ({
...theme.fonts.labelLarge,
color: textColor,
};

const IconComponent = animated ? CrossFadeIcon : Icon;
const NumberOfLines = numberOfLines ? numberOfLines : 1;
return (
<View style={[buttonStyle, styles.button, style]}>
<TouchableRipple
Expand Down Expand Up @@ -221,14 +233,18 @@ const SegmentedButtonItem = ({
) : null}
{showIcon ? (
<Animated.View testID={`${testID}-icon`} style={iconStyle}>
<Icon source={icon} size={iconSize} color={textColor} />
<IconComponent
color={textColor}
source={icon ? icon : 'progress-question'}
size={iconSize}
/>
</Animated.View>
) : null}
<Text
variant="labelLarge"
style={[styles.label, labelTextStyle, labelStyle]}
selectable={false}
numberOfLines={1}
numberOfLines={NumberOfLines}
maxFontSizeMultiplier={labelMaxFontSizeMultiplier}
testID={`${testID}-label`}
>
Expand Down
5 changes: 5 additions & 0 deletions src/components/SegmentedButtons/SegmentedButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type Props<T extends string = string> = {
* - `icon`: icon to display for the item
* - `disabled`: whether the button is disabled
* - `accessibilityLabel`: acccessibility label for the button. This is read by the screen reader when the user taps the button.
* - `numberOfLines`: label text number of lines of the button
* - `checkedColor`: custom color for checked Text and Icon
* - `uncheckedColor`: custom color for unchecked Text and Icon
* - `onPress`: callback that is called when button is pressed
Expand All @@ -65,6 +66,7 @@ export type Props<T extends string = string> = {
icon?: IconSource;
disabled?: boolean;
accessibilityLabel?: string;
numberOfLines?: number;
checkedColor?: string;
uncheckedColor?: string;
onPress?: (event: GestureResponderEvent) => void;
Expand All @@ -78,6 +80,7 @@ export type Props<T extends string = string> = {
* Density is applied to the height, to allow usage in denser UIs
*/
density?: 'regular' | 'small' | 'medium' | 'high';
animated?: boolean;
style?: StyleProp<ViewStyle>;
theme?: ThemeProp;
} & ConditionalValue<T>;
Expand Down Expand Up @@ -131,6 +134,7 @@ const SegmentedButtons = <T extends string = string>({
buttons,
multiSelect,
density,
animated,
style,
theme: themeOverrides,
}: Props<T>) => {
Expand Down Expand Up @@ -171,6 +175,7 @@ const SegmentedButtons = <T extends string = string>({
{...item}
key={i}
checked={checked}
animated={animated}
segment={segment}
density={density}
onPress={onPress}
Expand Down